我的 onchange
事件不会在第一个、第 3 个、第 5 个等处启用按钮,但我认为我的代码是最新的,这是我的代码
<button type="button" class="btn btn-outline btn-primary disabled" id="next" >Generate Report</button>
这些是下拉菜单
我的 Jquery
$("#advertiserId,#brandId,#campaignId").on('change',function(){
if ($("#advertiserId").val() && $("#brandId").val() && $("#campaignId").val() )
{
$("#next").removeClass('disabled');
}
else
{
$("#next").addClass('disabled');
}
});
下拉菜单 ID
advertiserId
、brandId
、campaignId
提前致谢
最佳答案
Bootstrap 下拉菜单不会触发“更改”事件,它们会被单击...您应该处理“单击”事件。
Look at this for an example...
Here are the docs ,还有更多特定于 Bootstrap 的事件...
最适合您的是:
show.bs.dropdown
This event fires immediately when the show instance method is called.
关于javascript - 更改下拉列表时禁用和启用按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30375739/