如何在jquery中单击按钮时启用已禁用的所选选择框?

时间:2014-12-20 04:38:54

标签: jquery jsp

如何在jsp中禁用页面加载时选择的选择框,然后如何在jQuery中单击按钮时启用所选的选择框? 在我的代码下面。

<select disabled="disabled"  class="chzn-select chosen-select-deselect chzn-select-width"  style="width: 100px"  id="workweekmonday" name="workweekmonday" >
<option value="0" selected="selected">Full Day</option>
<option value="4">Half Day</option>
<option value="8">Non-working Day</option>
 </select>
<div class="col-md-2  col-md-offset-3">
<button type="button" class="btn btn-theme02 btn-block" id="btnsaveworkweek">
<i class="fa fa-save"></i> Edit
</button>
</div>

2 个答案:

答案 0 :(得分:0)

$(document).ready(function(){
    $("select").chosen();
    $("#workweekmonday").prop('disabled', 'disabled');  //On load disabled select

    $("#btnsaveworkweek").click(function(){
       $("#workweekmonday").prop('disabled', false);   //On button click enabled select
     });
});

<强> JS Fiddle

答案 1 :(得分:0)

试试这个:

$("#btnsaveworkweek").click(function(){
    $("#workweekmonday").removeProp('disabled');  
});

演示: http://jsfiddle.net/66a15zoc/