Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
actulay
HTML
<div id="s">
<div id="s1">
</div>
</div>


<div id="s">
<div id="s1">
</div >
</div>
<div id="s">
<div id="s1">
</div >
</div>
<div id="s">
<div id="s1">
</div >
</div>
<div id="s">
<div id="s1">
</div >
</div>


on div click function how to get are set html
to s1 div
using jquery

when i finding with id its showing first div ="s1"
i want on div s on click s1 as respectevely
ex :- i click on

s div secodes on that contain inner s1
how to get inner s1 respectevely
Posted
Updated 22-Oct-12 0:16am
v3
Comments
Sergey Alexandrovich Kryukov 22-Oct-12 2:11am    
Why doing it this way?
--SA

1 solution

Here is the issue: this HTML document is invalid. It is required that each id attribute value should be unique in the whole HTML document. For example, please see:
http://www.w3schools.com/tags/att_global_id.asp[^].

Even though it won't be a problem to find any nested element by some non-unique attribute value based on nesting structure, especially with jQuery, in case of id the problem becomes really trivial; you only need to fix HTML. I would recommend to use jQuery, which has an attribute selector:
http://api.jquery.com/id-selector/[^].

See also:
http://api.jquery.com/category/selectors[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900