
我的onchange事件没有在第一个、3个、5个等等的按钮上打开enable,但我认为我的代码是最新的,这里是我的代码
<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');
}
});下拉ids
advertiserId、brandId、campaignId
提前感谢
发布于 2015-05-21 22:00:22
Bootstrap下拉菜单不会触发‘change’事件,它们会被点击...你应该处理‘click’事件。
Look at this for an example...
Here are the docs,还有很多特定于Bootstrap的事件...
适合您的是:
show.bs.dropdown此事件在调用show instance方法时立即激发。
发布于 2015-05-21 22:40:56
这些下拉菜单看起来不像引导程序中的下拉菜单。
所以我假设它是一个选择元素。
问题可能出在您的jQuery版本上,也可能出在您在选择元素内的option元素的值中。
例如,如果选项没有值
<option>first Option</option>对于if语句,这将表现为true。因此,您应该按如下方式设置该值:
<option value="">first Option</option>我在这里尝试了一些东西:https://jsfiddle.net/s82zcg4y/
https://stackoverflow.com/questions/30375739
复制相似问题