JQuery pass a variable from function to function -


i have variable retrieved via .click function , want pass function i"m having trouble passing correctly because when call other function nothing happens.

var classname; var flavor; (function ($) {    drupal.mytest = drupal.mytest|| {};    drupal.behaviors.mytest= {      attach: function (context, settings) {            drupal.mytest.myfunction= function (classname) {             var passedvar= classname;             alert(passedvar);           };              $('.buttons').on('click', function(event) {             classname = $(this).attr('class');           });            $('#test').on('click, function(event) {         drupal.mytest.myfunction();           });      }    };  }(jquery)); 

try

(function ($) {     var classname;     var flavor;      drupal.mytest = drupal.mytest|| {};      drupal.behaviors.mytest = {         attach: function (context, settings) {             drupal.mytest.myfunction= function (classname) {                 var passedvar= classname;                 alert(passedvar);             };              $('.buttons').on('click', function(event) {                 classname = $(this).attr('class');             });              $('#test').on('click', function(event) {                 drupal.mytest.myfunction(classname);             });         }     };  }(jquery)); 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -