在实现选择框中隐藏选项 [英] Hide option in materialize select box

查看:43
本文介绍了在实现选择框中隐藏选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对文档进行材料化- http://materializecss.com/forms.html

我想通过jquery隐藏Materialize选择选项.我在选项中添加了一个类,并通过使用此代码$('.break_5').hide();选项成功隐藏了.但是它显示在Materialize选择框中.

I want to hide Materialize select option by jquery. I added a class to an option and by using this code $('.break_5').hide(); option is hidden successfully. But it is displayed in Materialize select box.

推荐答案

根据文档,为了更新select内的项目,必须销毁材料并重新运行初始化.

According to the docs, in order to update the items inside the select, you must destroy the material and rerun initialization.

$('#mySelectID').material_select('destroy');

然后使用或不使用某些选项重新创建您的选择,并初始化新选择.

Then recreate your select with or without certain options and initialize new select.

$('#mySelectID option').hasClass('break_5').remove();
$('#mySelectID').material_select();

这篇关于在实现选择框中隐藏选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆