javascript - jquery toggle triggers display to none -


i have weird behavior. want trigger event on click on span tag, let's #span id. when run in console, test :

$('#span').toggle(function(){     console.log('hi'); },function(){       console.log('hey'); }); 

the #span display set none. tried find code interfere didn't find any...

this version of toggle removed in jquery 1.9, if using jquery >= 1.9 toggle display state

one possible solution enable removed functionalities add migration plugin after jquery

another write toggleclick plugin below 1 this answer

$.fn.toggleclick = function(){     var methods = arguments, // store passed arguments future reference         count = methods.length; // cache number of methods       //use return maintain jquery chainability     return this.each(function(i, item){         // each element bind         var index = 0; // create local counter element         $(item).click(function(){ // bind click handler element             return methods[index++ % count].apply(this,arguments); // when called apply 'index'th method element             // index % count means constrain our iterator between 0 , (count-1)         });     }); }; 

then

$('#span').toggleclick(function(){     console.log('hi'); },function(){       console.log('hey'); }); 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -