I'm trying to have a dropdown menu that enable/disable button, and I'm following this example
but it's 4 years old and the function doesn't seems to work on my xhtml page.
Any help would be appropriated
Here is a live demo: http://jsfiddle.net/txrkrgms/
using .prop() method on the button you like when the select is .change().
$("select").change(function() {
if($(this).val() == "on")
$("button").prop("disable", false);
else
$("button").prop("disable", true);
});
Hope is what you are searching for.
HTML:
<select id='ddlToggle'>
<option Value='1'>ON</option>
<option Value='0'>OFF</option>
</select>
<input type='button' id='btn1' Value='Hello' />
JQuery:
$("#ddlToggle").on("change", function(){
$("#btn1").prop("disable", $(this).val() == "0");
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.