Select specified div value
I have this HTML:
<div id="main"><div id="mainly">11</div><div id="mainly">22</div>&l开发者_JAVA技巧t;/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".
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');
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.
精彩评论