1

我有一个 html( index.html) 和一个 javascript( controller.js) 文件。有一个<div>index.html

<div id="tableContent"></div>

我正在向该 div 发送一个表格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'); 
});

表在 中正确显示index.html。但是当我更改选择下拉值时no alert is showing。I want to do some calculation when select option value changed.

提前致谢。

4

1 回答 1

3

改变

$(".playautofirst_withpartner").change(function(){

$(document).on('change','.playautofirst_withpartner',function(){

您需要使用DOM稍后添加的事件委托。

于 2013-08-27T03:42:01.013 回答