Laravel-如何基于dropdownlist值隐藏div元素

Laravel-如何基于dropdownlist值隐藏div元素,laravel,Laravel,我的Web应用程序项目中有这个Laravel-5.8代码 控制器 public function create() { $userCompany = Auth::user()->company_id; $goaltypes = AppraisalGoalType::where('company_id', $userCompany)->get(); $categories = AppraisalGoalType::with('children')-&

我的Web应用程序项目中有这个Laravel-5.8代码

控制器

public function create()
{
  $userCompany = Auth::user()->company_id;   
  $goaltypes   =       AppraisalGoalType::where('company_id', $userCompany)->get(); 
  $categories = AppraisalGoalType::with('children')->where('company_id', $userCompany)->whereNotNull('parent_id')->get();

return view('goals.create')
        ->with('goaltypes', $goaltypes)
        ->with('categories', $categories);
}
视图刀片


{{csrf_field()}}
目标类型:*
选择目标类型
@foreach($categories作为$category)
id==old('category_id')?'所选“:”}>{{$category->name}
@如果($category->children)
@foreach($category->children as$child)
id==old('category_id')?'所选“:”}>{{$child->name}
@endforeach
@恩迪夫
@endforeach

使用Jquery,您可以执行以下操作:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>  
<script>       
    $(document).ready(function () {              
    $('select').on('change', function() {
                    if( this.value === 'Simon') $('.textarea').hide();
                });
    });
</script>

$(文档).ready(函数(){
$('select')。在('change',function()上{
if(this.value==='Simon')$('.textarea').hide();
});
});
解释:

第一个脚本在页面中加载Librarie Jquery 第二个脚本,一旦dom就绪,select的“onchange”事件将调用将当前值与“Simon”进行比较,如果相等,则文本区域将被隐藏