我有一个选择列表,其中包括"全部"和"自定义".在选择值为'custom'时,应显示带有"资源"类的div,如果值为"all"则应隐藏.
表格是:
<div>
<label>Privileges:</label>
<select name="privileges" id="privileges" class="" onclick="craateUserJsObject.ShowPrivileges();">
<option id="all" value="all">All</option>
<option id="custom" value="custom">Custom</option>
</select>
</div>
<div class="resources" style=" display: none;">resources</div>
Run Code Online (Sandbox Code Playgroud)
这个javascript是这样的:
ShowPrivileges: function() {
var Privileges = jQuery('#privileges');
var select = this.value;
Privileges.change(function() {
if (select === 'custom') {
$('.resources').show();
}
});
}
Run Code Online (Sandbox Code Playgroud)
为了工作,这应该怎么样?对不起,我知道这应该很简单,但我对这一切都很新.
我有这个具有多个数据属性的按钮,我想通过基于类和两个数据属性选择它来隐藏它.
<a href='#' class='wishlist-icon' data-wish-name='product' data-wish-url='/product'>Button</a>
$(".wishlist-icon [data-wish-name='product'] [data-wish-url='/product']").hide();
Run Code Online (Sandbox Code Playgroud)
我不知道为什么这个选择器不起作用.