i am using a toggle function such that when i click on a button a div shows up and when i again click that button it hides . but the problem is i also have one more close button in the div that closes the div, it means when i clicked the button the toggle was incomplete and when i try to open the div again through that toggle button then first it completes the toggle means again hide the already hidden div and then again show it , any solution for that ?
$(".stngs").toggle(function() {
$(".stngsubmenu").css({
display: 'block'
});
}, function() {
$(".stngsubmenu").css({
display: 'none'
});
});
According to http://api.jquery.com/toggle/ you can just pass a boolean into the toggle
or
true will show element and false will hide which the .is() function will return a boolean
$(".stngsubmenu").is(':visible')// <– will return true if visible$(".stngsubmenu").is(':hidden')// <– will return true if hiddenhttp://jsfiddle.net/wirey00/KXPBq/