javascript - How do I push new element with the given text to an array of selected html elements? -
this selected html elements:
var array = jquery.makearray($(".dersprg tr td:nth-child(6)"));
this selects table info consists of table header text , irrelevant data. can interpret irrelevant info using if statements , extract info need, can not force array since types not same suppose. code this:
for(i=0 ; i<array.length ; i++){ content = array[i].innerhtml; if(some conditions){ array.splice(i--,1); //eliminate non day elements array.push('test input <br>'); //problematic line } }
you see, utilize innerhtml
compare content of selected <td>
element, when comes adding test input
whole array renders empty. think due type mismatch, not figure out how can solve this. help highly appreciated.
try :
var cell=document.createelement('td'); cell.appendchild( document.createtextnode('test input <br>') ); array.push(cell);
this insert <td>
in array instead of string.
javascript arrays
No comments:
Post a Comment