Pierce McGeough
Pierce McGeough

Reputation: 3086

Find the jQuery toggle state

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

Answers (2)

Justinas
Justinas

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

Deep Sharma
Deep Sharma

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

Related Questions