在PHP / Laravel中选中切换时隐藏元素

时间:2018-01-05 22:26:42

标签: php html laravel

当我单击切换时我试图隐藏页面上的元素,当我再次单击切换时取消隐藏它。这是我的HTML代码:



true




故障:

因此,当我点击<div class="form-group settings-row"> {{ Form::label('notificationSettings', 'Notification Settings', array('class' => 'col-md-2 control-label')) }} <div class="col-md-10"> <table style="border-width:0; margin-top:4px;"> <tr> <td> Notifications Enabled </td> <td> <div class="onoffswitch" style="margin:4px 0 0 7px;"> <input type="checkbox" @if($notificationsEnabled == true)checked @endif name="notifications_toggle" class="onoffswitch-checkbox" id="notifications_toggle"> <label class="onoffswitch-label" for="notifications_toggle"> <span class="onoffswitch-inner"></span> <span class="onoffswitch-switch"></span> </label> </div> </td> <td></td> </tr> </table> <div class="col-md-10"> @foreach($notificationMessageRadios as $radio) @if(isset($radio['text'])) <div class="row" style="margin-bottom:1em;"> <input type='radio' name='notificationMessage' id="notificationmessage-other" value="" @if($radio['selected']) checked @endif> {{$radio['message']}} </div> <input type="text" id="notificationMessageCustom" placeholder="Pick your own!" @if($radio['selected'])value="{{ $settingsForMessages->notification_message }}" @else value="Pick your own!" @endif name="notificationMessageCustom" class="form-control" @if(!$radio['selected'])style="display:none"@endif> @else <div class="row"> <input type='radio' name='notificationMessage' value="{{ $radio['message']}}" @if($radio['selected']) checked @endif> {{ $radio['message'] }} </div> @endif @endforeach </div> </div> </div>时,我希望无线电显示。当我点击onoffswitch关闭时,我希望无线电消失。

我被投入到这个项目中,所以这段代码已经存在,我的任务是编辑一些功能。任何形式的帮助将不胜感激。

作为奖励,这是控制器方面:

&#13;
&#13;
onoffswitch
&#13;
&#13;
&#13;

我不是在寻找手持。我正在寻找指导,就是这样。

1 个答案:

答案 0 :(得分:1)

也许试试jQuery?

尝试jQuery Toggle:https://www.w3schools.com/jquery/eff_toggle.asp

$("button").click(function(){
    $("p").toggle();
});

这是链接中的代码副本。只需定位需要点击的顶行 $(“按钮”)中的“类”,“ID”,“元素”,然后定位需要显示/隐藏的元素 $( “p”)