jquery ui按钮造成麻烦

时间:2013-08-12 09:46:50

标签: jquery-ui jquery-ui-button

<table class='dates'>
 <form method='post' action='' name='admin' id='form_admin'>
  <tr>
   <td>Start Time Of Election</td>
   <td>: <input type="text" id="stime" name='elect' placeholder='hh:mm' readonly="true"/></td>
  </tr>
  <tr>
   <td>End Time Of Election</td>
   <td>: <input type="text" id="etime" name='elect' placeholder='hh:mm' readonly="true" disabled='true'/></td>
  </tr>
  <tr>
   <td align='right'>
    <input id='enable' type='submit' name='date' value='Update' disabled='true'/>
   </td>
   <td align='right'>
    <input type='submit' name='cancel' value='Cancel'/>
   </td>
  </tr>
 </form>
</table>

<script type="text/javascript">
$(function(){
 $('#stime').timepicker({
    hourMin: 8,
    hourMax: 10,
    onSelect: function(){
     $('#etime').prop('disabled', false);
     $('#etime').timepicker({
      hourMin: 16,
      hourMax: 18,
      onSelect: function(){
        $('#enable').prop('disabled', false);
     }
    });
   }
  });
});
</script>

我的代码适用于jQuery UI,datepicker和时间选择器,我的更新按钮在选择结束时间时启用。但当我使用jQuery UI按钮给我的按钮一个漂亮的外观,使用此代码

$(function() {
    $( "input[type=submit], button" )
      .button()
      .click(function( event ) {
      });
});

虽然我得到了样式,但我的更新按钮永远不会启用。

1 个答案:

答案 0 :(得分:1)

尝试

$("#enable").button( "enable" );

请参阅jQuery doc here