How to get id from below html string

When using the selector

$(this).children('td ').eq(0).html() 

      

I get

<input name="abc" type="checkbox" value="checked" class="check2" id="xyz" checked="">

      

I want to get "id" from this input element.

+3


source to share


2 answers


$(this).children('td:first').find('input[type="checkbox"]').prop('id');

      



+2


source


faster

var $t=$(this);

$t.find("> td:first-child").get(0).id

      

change answer to comment that disappears:



Current Winner

Cached.find ()

var $ a = $ ('# a'); $ A.find ('b.');

http://vaughnroyko.com/the-real-scoop-on-jquery-find-performance/

0


source







All Articles