Each row in my table has a dropdown. the values in the dropdown are "Edit" and "Cancel". i want to write a jquery selector which will return me all dropdowns with has a selectedvalue as "Edit". how do i do it?
name of edit control is same for all rows. am forming edit control dynamically like this. below code is inside a loop.
$tr.append(
'<td>' +
'<select id=\"editOption\">' +
'<option value=\"'+pkid+'_select\"></option>' +
'<option value=\"'+pkid+'\">Edit</option>' +
'<option value=\"'+pkid+'\">Cancel</option>' +
'</select>' +
'</td>'
);
As per the suggestion i changed the code to
'<td>' +
'<select id=\"editOption_'+pkid+'\" class=\"editOption\">' +
'<option value=\"-1\"></option>' +
'<option value=\"Edit\">Edit</option>' +
'<option value=\"Cancel\">Cancel</option>' +
'</select>' +
'</td>'
and when I use this:
var editedRows = $("table tr select").filter(function() {
return $(this).find("option").value == "Edit"; //This should be value, but for your code, its text()
});
console.log(editedRows.length);
length is coming as zero.