Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to hide modal with jquery?

button

<button type="button" class="btn" onclick="CountClass()" runat="server" data-toggle="modal" data-target="#inlineForm1">OPEN</button>

modal

<div class="modal fade text-left" id="inlineForm1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel34" aria-hidden="true">
some code
</div>

JavaScript:

function CountClass() {
   if(some code){
      $('#inlineForm1').modal('hide');
   }
}

why is not it working??


2 Answers

$(document).ready(function(){
$('.modal').modal('hide');
});
like image 107
Naveed Avatar answered Nov 25 '25 16:11

Naveed


You didn't say what your if expression needs to be, so I'm not addressing that, but to hide something with jQuery you can just use .hide() on the element you select.

$('#inlineForm1').hide();

Behind the scenes, this adds style="display:none" to the element, and the opposite, .show() removes this. Knowing this, you can also override the behavior with CSS or start it in one state or the other.

like image 37
tmdesigned Avatar answered Nov 25 '25 16:11

tmdesigned



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!