jquery - Returning variables outside a function -


i have been having problems returning variable through jquery function.

$(document).ready(function () {     var selected = "";      $('.whitetheme').on('click', function () {         $(this).effect("highlight", {}, 2000);         selected = "whitetheme";         return selected;          $('.blacktheme').fadeout(1500);         $('.redtheme').fadeout(1500);      })      console.log(selected); }); 

i trying have value of selected changed "whitetheme" once clicked.

right now, log function returns empty string.

you're binding event handler (and if invoked) change variable value. however, event cannot occur before console.log executed, don't see updated value.

also, blacktheme , redtheme classes not faded out, since code part unreachable.

what trying achieve?


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

monitor web browser programmatically in Android? -

c# - Using multiple datasets in RDLC -