Reputation:
I have this HTML:
<div id="main"><div id="mainly">11</div><div id="mainly">22</div></div>
I want to select the div with value 11.How to do this? I tried:
$("<div id="mainly">11</div>")
,but it didn't work... I don't have only two divs with id="mainly".
Upvotes: 1
Views: 146
Reputation: 236022
I don't have only two divs with id="mainly"
But you should have only one div with the id "mainly" !
DOM identifiers have to be unique in order to create a "well formed" and valid markup.
So, we just assume you'are using classes
instead of ids
.
$('.mainly:contains(11)').fadeOut('fast');
Upvotes: 2
Reputation: 104178
You can't have two or more div elements with the same id. This is invalid html and jQuery selectors won't work. Instead of ids use a common class for all the elements.
Upvotes: 2