Thursday, April 25, 2024
 Popular · Latest · Hot · Upcoming
rated 0 times [  43] [ 2]  / answers: 1 / hits: 21340  / 14 Years ago, tue, june 22, 2010, 12:00:00

I know, that two elements can't hav the same id. But it's happens so, that in my project I have two elements with same id in other divs, like this

<div id="div1">
<img id="loading" />
<div id="div2">
<img id="loading" />

And CSS:

#div1 #loading
some style here...
#div2 #loading
another style here...

Works fine for me, but maybe it is not reccomended to do by so?

Yes, I know, thet I can use classes, and it's strongly recomended to do by so, but I want to know is there any potential risk in this usage of id?
I think no, because when I wrote for example

$("#div1 #loading")... it becomes a unique element.
Isn't it?

More From » jquery




If you need it in your project, you can use it, like suggested in my Question Final Update!

[#96431] Friday, June 18, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 743
Total Questions: 113
Total Answers: 128

Location: Suriname
Member since Sun, Jun 13, 2021
3 Years ago