[英]Dropdown that enable/disable button
Here is a live demo: http://jsfiddle.net/txrkrgms/ 这是一个现场演示: http : //jsfiddle.net/txrkrgms/
using .prop() method on the button you like when the select is .change(). 选择为.change()时,在您喜欢的按钮上使用.prop()方法。
$("select").change(function() {
if($(this).val() == "on")
$("button").prop("disable", false);
else
$("button").prop("disable", true);
});
Hope is what you are searching for. 希望是您要寻找的。
HTML: HTML:
<select id='ddlToggle'>
<option Value='1'>ON</option>
<option Value='0'>OFF</option>
</select>
<input type='button' id='btn1' Value='Hello' />
JQuery: jQuery的:
$("#ddlToggle").on("change", function(){
$("#btn1").prop("disable", $(this).val() == "0");
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.