Bootstrap 按钮下拉列表中的更改事件不起作用。可能是什么原因?如何解决这个问题?
下面是我的 fiddle 。我想触发一个复选框更改事件,但令人惊讶的是下面的代码没有触发。
<a href="http://jsfiddle.net/20hLtzvr/18/" rel="noreferrer noopener nofollow">http://jsfiddle.net/20hLtzvr/18/</a>
$('#chk0').click(function()
{
alert('hello world');
});
最佳答案
您在设置 ID 时忘记了"
替换
$('#citycountylist ul').append('<li><a href="#"><input type="checkbox" class="chk" id=' + 'chk' + index + ' />' + ' ' + json.NewYork[index].name + ' </a></li>');
由
$('#citycountylist ul').append('<li><a href="#"><input type="checkbox" class="chk" id="' + 'chk' + index + '" />' + ' ' + json.NewYork[index].name + ' </a></li>');
关于javascript - 如何处理 Bootstrap 按钮下拉列表中的点击事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25778388/