My control is built dynamically in accordance with user input, there are n text fields whose identifiers are also dynamic.
However, I did not foresee that this HTML would be used elsewhere on the same HTML page.
The problem I'm currently facing is duplicate identifiers, due to which my jQuery functions do not work.
I understand that identifiers must be unique, however, can I avoid this problem by using an external <div> with different identifiers?
Any experts can give me good advice?
PS I am looking for an effective solution, because if I need to change the identifier for each element, it will require a lot of work in my jQuery.
Please help. Thanks!
<div id="Container1"> <div id="Control"> <input type="text" id="TextBox1" /> <input type="text" id="TextBox2" /> </div> </div> <div id="Container2"> <div id="Control"> <input type="text" id="TextBox1" /> <input type="text" id="TextBox2" /> </div> </div>
I am wondering if in jQuery functions I can do something like .. #container1 > #textbox1 in the selection?
javascript jquery html
pekcheng
source share