这似乎是一件相当简单的事情,但这个问题已经给我带来了很长一段时间的麻烦。I have a submit button that is 'disabled' when a select list value is 'select'. 我想要的是 html('select an area')...但是按钮被禁用。这是代码:
<script>
//setting the variable for first-shown select value
var selVar = $('#areaSel').val();
//disabling submit if first-shown value is 'select'
if(selVar == 'select'){
$('#areaSubmit').prop('disabled',true);
}
//setting the variable if the selection changed & disabling submit if = 'select'
$('#areaSel').change(function(){
var selVar = $('#areaSel').val();
if(selVar == 'select'){
$('#areaSubmit').prop('disabled',true);
//removing 'disabled' submit if selection !== select
}else{
$('#areaSubmit').prop('disabled',false);
}
});
//giving the message to 'select an area
$('#areaSubmit').click(function(){
var selVar = $('#areaSel').val();
if(selVar == 'select'){
$('#areaE').html('select an area');
}
});
</script>
我只是想让消息“选择一个区域”出现,而不是在单击时提交。问题是选择“选择”时禁用按钮。在此先感谢您的帮助!