简体   繁体   中英

How to disable and enable datetimepicker jquery plugin

I have a requirement like enabling and disabling datetimepicker plugin from input box.

<select id="sel">
<option value="opt1" data-type="date">opt1</option>
<option value="opt2" data-type="string">opt2</option>
</input><input id="inp">

<script>
$('#sel').on('change', function(){
   var type = $('this').find('option:selected').data(type);
   if(type == 'date'){
      //enable calendar
      $('#inp').datetimepicker();
   } else {
      //need to disable
   }
});
</script>

Want to enable if type is date if not need to disable calendar. Any help appreciable.

If you'll find time and read datetimepicker manual you will see a couple of methods even with examples:

hide - Hide Datetimepicker

toggle - Show/Hide Datetimepicker

destroy - Destroy datetimepicker

Now, choose which one you want.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM