Close jQuery thickbox on button click

sudeep cv picture sudeep cv · Jul 6, 2012 · Viewed 12.2k times · Source

Here is my jQuery:

<script src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/thickbox.js"></script>
<script type="text/javascript"

$('#button').click(function(){
     $('#TB_window').fadeOut();
});

</script>

Html:

  <input type="submit" id="button" value="clse" >

I tried this function, but it's not working.

Answer

Makarand Mane picture Makarand Mane · Jan 19, 2014

Thickbox have their built in method. tb_remove just call this method tb_remove(); wherever you need. It will close thickbox properly.

If you use $('#TB_window').fadeOut(); , TB_overlay DIV will remain open. If you again do something nonsense like $('#TB_overlay').fadeOut(); then it will create problem for your thickbox. And thickbox will stop function.