Identify the cell containing a particular class using javascript / jQuery -


i have

var output = '<tr>'+                '<td class="class1">one</td>'+                '<td class="selected">two</td>'+                '<td></td>'+                '<td></td>'             '</tr>'; 

how can identify cell (1,2,3 or 4) has class="selected"

console.log($(output).find('.selected').index()); 

jsfiddle example

and remember .index() zero-based.


Comments

Popular posts from this blog

css - I want to align grid in center -

Contact Form PHP Email Script -

python - SWIG function not printing output -