Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

jquery selector syntax question.



8:21 pm on May 18, 2012 (gmt 0)

5+ Year Member

hi all,

I have a jquery selector defined in my javascript to load the contents of a table element. It appears to work but i'm not sure if the syntax is correct and might be causing me problems.

I'm trying to access a select tag in a table who's rows containing the select tag are dynamically appended to the empty tbody.

The table is defined as...

<table id="sa-table-2">


The javascript code is as follows...

// get all work order items.
for(i = 0; i < response.records; i++){
row = response.rows[i]; // row is cell array shortcut.

var id = row["cell"]["0"];

// append the select element row to the tbody.
$('#sa-table-2 tbody').append(
'<tr id="'+id+'"><td><select name="wi-PLID" class="wi-PLID"></select></td></tr>'

'tr#'+id+' select[name="wi-PLID"]'
).load('php/script.php', data, function(data){$(
'tr#'+id+' select[name="wi-PLID"]'
).html(data.replace( blah blah blah ));});


Is the bolded selector definition correct for the bolded table row being appended?


10:02 pm on May 18, 2012 (gmt 0)

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

As long as id is unique, that should work, though the callback function sets this to the DOM element being operated on (which is the select element), so you're better off to use $(this) in place of the selector you're using in the callback so that it doesn't need to search for it again.


11:45 pm on May 18, 2012 (gmt 0)

5+ Year Member

thanks again.

Featured Threads

Hot Threads This Week

Hot Threads This Month