我有一个带有两个按钮的下拉菜单,如下所示
<select id="BrandNames" class="m-wrap" tabindex="1" style="width:100%;">
<option class="placeholder" selected="" disabled="">Select Brand</option>
<option value="3000">General</option>
<option value="3001">KFC</option>
<option value="3002">Chutneys</option>
</select>
<input type="button" id="prev" value="prev">
<input type="button" id="next" value="Next">
$(document).on('click', '#prev', function(event ) {
alert('Prev button called');
});
$(document).on('click', '#next', function(event ) {
alert('Next button called');
});
假设我从下拉菜单中选择了“常规(首选)”。
我的要求是,如果我选择“下一个”按钮或“上一个”按钮,则如何使下拉菜单返回到默认选择(在我的情况下为“选择品牌”)?
这是我的jsfiddle
有人可以帮忙吗?
HTML:-
<select id="BrandNames" class="m-wrap" tabindex="1" style="width:100%;">
<option class="placeholder" selected="" disabled="" value="">Select Brand</option>
<option value="3000">General</option>
<option value="3001">KFC</option>
<option value="3002">Chutneys</option>
</select>
<input type="button" id="prev" value="prev">
<input type="button" id="next" value="Next">
如上图所示,value=""
在Select Brand
下拉菜单中添加选项。
jQuery的:-
$(document).on('click', '#prev', function(event ) {
alert('Prev button called');
$('#BrandNames').val(''); //select first option
});
$(document).on('click', '#next', function(event ) {
alert('Next button called');
$('#BrandNames').val(''); //select first option
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句