$("#divTest").delegate('table select', 'change', function () {
var tempddl1 = $(this).parent().find("select option:selected").eq(0).text();
var tempddl2 = $(this).parent().find("select option:selected").eq(1).text();
alert("do something");
});
<div id="divTest">
<table><tr><td>
<select>
<option>One</option>
<option>Two</option>
</select>
Some seperation
<select>
<option>One1</option>
<option>Two1</option>
</select>
</td></tr></table>
<table><tr><td>
<select>
<option>One</option>
<option>Two</option>
</select>
Some seperation
<select>
<option>One1</option>
<option>Two1</option>
</select>
</td></tr></table>
</div>
//to do an action on the change of any SELECT inthe parent DIV
//use delegate
var tempddl1 = $(this).parent().find("select option:selected").eq(0).text();
var tempddl2 = $(this).parent().find("select option:selected").eq(1).text();
alert("do something");
});
<div id="divTest">
<table><tr><td>
<select>
<option>One</option>
<option>Two</option>
</select>
Some seperation
<select>
<option>One1</option>
<option>Two1</option>
</select>
</td></tr></table>
<table><tr><td>
<select>
<option>One</option>
<option>Two</option>
</select>
Some seperation
<select>
<option>One1</option>
<option>Two1</option>
</select>
</td></tr></table>
</div>
//to do an action on the change of any SELECT inthe parent DIV
//use delegate
No comments:
Post a Comment