Reputation: 3086
How can I find the toggle state within a function? Does the function have a built in feature which will tell me i.e. toggle=on or toggle=off
Upvotes: 1
Views: 3847
Reputation: 43479
Do you mean check if element is visible or not? .toggle() change css "display:none;" to "display: block;". Check:
$('#element').attr('display') == 'none' ? state = 'on' : state = 'off';
Upvotes: 1
Reputation: 3473
i guess there is no pre-defined functions but you have to use this
var state = $(this).is(":hidden");
alert(state);
Upvotes: 2