Jquery禁用启用按钮,下拉选择
我有一个下拉菜单,我想在选择某个值时禁用/启用页面上的按钮。它适用于除 IE7 及更低版本之外的所有浏览器。有解决办法吗?
代码:
<script type="text/javascript">
$(document).ready(function() {
//Start Buttons
$(".nextbutton").button({ disabled: true });
(".nextbutton").click(function() { $("#phonetypeform").submit() });
//Enable Next Step
$('.enablenext').click(function(){
$(".nextbutton").button("enable");
});
//Disable Next Step
$('.disablenext').click(function(){
$(".nextbutton").button("disable");
});
});
</script>
<form>
<select name="porting-p1"class="dropdown">
<option value="" class="disablenext">Please select an option...</option>
<option value="1" class="enablenext">I want to keep my current phone number</option>
<option value="2" class="enablenext">I want to choose a new number</option>
</select>
</form>
<button class="nextbutton">Next Step</button>
I have a dropdown menu and I want to disable/enable a button on my page when a certain value is selected. It works in all browsers but IE7 and below. Is there a work around?
Code:
<script type="text/javascript">
$(document).ready(function() {
//Start Buttons
$(".nextbutton").button({ disabled: true });
(".nextbutton").click(function() { $("#phonetypeform").submit() });
//Enable Next Step
$('.enablenext').click(function(){
$(".nextbutton").button("enable");
});
//Disable Next Step
$('.disablenext').click(function(){
$(".nextbutton").button("disable");
});
});
</script>
<form>
<select name="porting-p1"class="dropdown">
<option value="" class="disablenext">Please select an option...</option>
<option value="1" class="enablenext">I want to keep my current phone number</option>
<option value="2" class="enablenext">I want to choose a new number</option>
</select>
</form>
<button class="nextbutton">Next Step</button>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
IE7 似乎不喜欢
标签上的点击事件。
这是一个简短的演示,应该适合您使用
change()
事件代替。IE7 doesn't seem to like the click event on
<option>
tags.Here's a short demo that should work for you using the
change()
event instead.你试过
了吗
?
华泰
Have you tried
and
?
HTH