开发者

How do you delete divs that have the same ids but their dispaly properties are different

开发者 https://www.devze.com 2022-12-28 04:41 出处:网络
i have two divs with the same ids but one has di开发者_如何学JAVAsplay=none and the other has display=block

i have two divs with the same ids but one has di开发者_如何学JAVAsplay=none and the other has display=block i want to delete the one with display='none' i am using javascript framework prototype


You cannot have two controls with the same ID, it is invalid. You should rewrite your code so the IDs are not the same.


You should switch to giving the divs classes instead of id's. ID's are unique identifiers, thus are unique, and a page should only contain one element per id (an id can not have multiple elements).

If you'd gave the divs classes instead of id's you could do this:

$$(".<your_class_here>").reject(Element.visible).each(Element.remove);

My Prototype is a bit rusty, but I think this should do it.

EDIT: forgot you can't directly filter by CSS properties.


You shouldn't have two elements with the same ID. You should use classes.

0

精彩评论

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