Monday, January 12, 2015

[jQuery] Hide bootstrap's datepicker after selected the date

This is a method to hide datepicker menu after the date selected:
<input id="article_post_fromdate" name="article_post_fromdate" class="span6" type="text" readonly="readonly" onchange="hideDatePicker()"/><span class="add-on"><i class="splashy-calendar_day"></i></span>
<- if the value of the textbox which recorded the date changed , call hideDatePicker() function.

By default, datepicker menu were with the class “.datepicker”, hideDatePicker() function is for added the css inline style: display:none to hide datepicker menu.
<script type="text/javascript">
    jQuery('.date').datepicker(); // init the datepicker
    function hideDatePicker(){ //if user select the date value, hide the displayed menu.
        jQuery('.datepicker').css('display',"none");
    }

</script>

No comments :

Post a Comment