javascript - Iterating through elements returned by jQuery selector -


i have html that's structured more or less want able filter though row.

<div class="parentelement">    <div class="rowinput">       <input type="checkbox" />       <input type="text" value="demo" />    </div>     <div class="rowinput">       <input type="checkbox" />       <input type="text" value="demo" />       <select>           <option>value 1</option>          <option>value 2</option>       </select>    </div> </div> 

i'm able 2 rows need

var row = $('.rowinput');  0: div.row.inputrow 1: div.row.inputrow 

however i'm having issues going through these rows , further , pulling out information. i've tried few different methods of looping through rows best i've been able traversing property list of elements. want go through each element of div.row.inputrow , pull out information based on element type can store information row.

edit: able wanted following code:

for (var = 0; < rows.length; i++) {         console.log(rows[i]);     (var j = 0; j < rows[i].childnodes.length; j++) {             console.log(rows[i].childnodes[j]);     } } 

however i'm getting errors whenever try use jquery '.is()' on child nodes i'm returning

uncaught typeerror: rows[i].childnodes[j].is not function 

basically i'm going in end returning each element '.inputrow' can filter out input of each row , either store or discard based on if checkbox selected. main reason i'm going route couldn't input needed row both 'select' , ':input' selector.

your code correct except way childerens try following:

var rows = $('.rowinput');  (var = 0; < rows.length; i++) {   console.log(rows[i]);   (var j = 0; j < $(rows[i]).children().length; j++) {     console.log( $(rows[i]).children()[j]);   } } 

check here: jsfiddle


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -