This feels like a really basic question…that I cant find the answer for! Just a basic jQuery click function:
$('button.one').click(function () {
var selectorVal = 'one';
$('div#one').slideDown('slow');
$('div#two').slideUp('fast');
return selectorVal;
}
How do I retrieve and output selectorVal outside the function? Thanks so much!
You have two options:
Define variable outside the callback:
(better) Use another callback:
As I mentioned above, the second option is the better option, as using callback in this case is best suited.