开发者

Select specified div value

开发者 https://www.devze.com 2023-01-05 18:01 出处:网络
I have this HTML: <div id=\"main\"><div id=\"mainly\">11</div><div id=\"mainly\">22</div>&l开发者_JAVA技巧t;/div>

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号