3

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

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. Commented Sep 14, 2013 at 10:43

1 Answer 1

7

Just remove the space between the selector.

$(".wishlist-icon[data-wish-name='product'][data-wish-url='/product']").hide();

Js Fiddle Demo

Sign up to request clarification or add additional context in comments.

1 Comment

I know, i just had to wait for certain period :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.