admin管理员组文章数量:1334165
I have this button with multiple data attributes, and i want to hide it by selecting it based on class and two data attributes.
<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();
I don't know why this selector doesn't work.
DEMO
I have this button with multiple data attributes, and i want to hide it by selecting it based on class and two data attributes.
<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();
I don't know why this selector doesn't work.
DEMO
Share Improve this question asked Sep 14, 2013 at 10:27 DušanDušan 4982 gold badges9 silver badges23 bronze badges 1-
1
The space is the descendant selector. You are looking for an element
[data-wish-url='/product']
inside an element[data-wish-name='product']
inside an element.wishlist-icon
. If you want to select an element based on multiple selectors, you have to write them together. – Felix Kling Commented Sep 14, 2013 at 10:43
1 Answer
Reset to default 7Just remove the space between the selector.
$(".wishlist-icon[data-wish-name='product'][data-wish-url='/product']").hide();
Js Fiddle Demo
本文标签: javascriptjQuery selector for HTML5 data attributesStack Overflow
版权声明:本文标题:javascript - jQuery selector for HTML5 data attributes - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742364838a2461080.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论