Reputation: 1949
I have the following:
<article id="post-43" class="like"></article>
<article id="post-56" class="like"></article>
<article id="post-78" class="dislike"></article>
<article id="bob" class="like"></article>
I want to hide all the articles that have ID beginning with "post-" that also have the class "like" using jQuery.
I have tried this:
$('#show_likes').on('click', function() {
$('input[name^="post-"].like').hide();
});
But it doesn't work.
Can someone help?
Upvotes: 3
Views: 14023
Reputation: 48813
Use article
instead of input
,and id
instead of name
:
$('article[id^="post-"].like').hide();
Upvotes: 12