Thursday, April 27, 2017

JQuery- in body click div hide, when i click on div also it hide

<label id="label-search">Search</label>
<input id="search" style="display: none;" name="q" value="" type="search">


<script>
jQuery(document).ready(function() {
    jQuery("#label-search").click(function(e) {
        jQuery("#search").show();
        jQuery("#label-search").hide();
        e.stopPropagation();
    });

    jQuery(document).click(function(e) {
        if (!jQuery(e.target).is('#label-search, #search')) {
            jQuery("#search").hide();
            jQuery("#label-search").show();
        }
    });
});
</script

No comments :

Post a Comment