javascript - JQuery Selector for multiple elements of one ancestor -


i have dom structure similar this:

<div id="ans1">     <input id="in1" />     <input id="in2" /> </div> <div id="ans2">     <input id="in1" />     <input id="in2" /> </div> 

how can select of descendants of ancestor?

something like:

$("#ans1 #in1, #ans1 #in2") 

you can use children function

$("#ans1").children("#in1, #in2") 

you should use unique ids thought dom, use classes specify elements same in nature.

change children have same class of in1

$("#ans1 > .in1") 

will select direct descendants of ans1 class of in1.


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -