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?
Use article
instead of input
,and id
instead of name
:
$('article[id^="post-"].like').hide();