Reputation: 611
I have a html(index.html
) and a javascript(controller.js
) file. There is a <div>
in index.html
<div id="tableContent"></div>
I am sending a table to that div from controller.js
.
var table = "<table border='1' class='table table-bordered TextHighlight'>"+
"<tr><th>Your Score</th></tr>"+
"<tr><td id='score1'><select id='partner_SC1' class='playautofirst_withpartner' name='partner_SC1'><option value='0'>0</option><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option></td></tr>"+
"</table>";
$("#tableContent").html(table);
$(".playautofirst_withpartner").change(function(){
alert('working');
});
Table is showing properly in index.html
. But when i change select dropdown value no alert is showing
. I want to do some calculation when select option value changed.
Thanks in advance.
Upvotes: 1
Views: 117
Reputation: 27382
Change
$(".playautofirst_withpartner").change(function(){
TO
$(document).on('change','.playautofirst_withpartner',function(){
You need to use event delegation for DOM
which are added later.
Upvotes: 3