Friday, 15 July 2011

jquery - Two functions on a single element; disable first while second run and vice versa -


Help me to use

As you've seen in the title, I have the same There are two functions on the element and i want to disable one during running each other.

  function SetupClick () {$ ("# wp"). "Width": "500"}, "slow");}, function () {$ ("# wp"), toggle (function () {$ ("# wp"). ({"Width": "100"}, "Slow");}; } Function SetupMOICEOver () {$ ("# wp"). Emulator ($ {"width": "500"}, "slow");};); $ ("# Wp"). Mouseout (function () {$ ("# wp"). Animate ({"width": "100"}, "slow");}); } $ ('# Ck') (function () {SetupClick (); // Alternatively, save the option to localsteas ['userchoice'] = 'click';}); $ ('# M') (Function () {SetupMouseover (); // Alternatively, the option to use local storage ['userchoose'] = 'mouseover';};    

user136etcetc provides a good link describing event namespacing in jQuery. Using the namespace in practice, here is your example:

  var aniMinWidth = 100; var aniMaxWidth = 500; function SetupClick () {// Mouse Event Delete first $ ("# wp"). .bobsyouruncle "); $ (" # wp ") (" mouseenter.bobs Youruncle "); $ (" click.bobsyouruncle ", function () {var animateWidth = $ (this). Width ()> Animminwidth? Animminwidth: animmaxwidth; $ (this). Animate ({"width": "slow"};});} function SetupMouseover () {// Remove the event first $ ("# wp"). Close ("click.bobsyouruncle"); $ ( Animate ({"width": aniMaxWidth}, "slow");}); $ ("# wp"). ("Mouseenter.bobsyouruncle", function () {$ ("# wp"). ). ("Mouseout.bobsyouruncle", function () {$ ("# wp"). Animate ({"width": animminwidth}, "slow");}); } $ ('# Ck') (function () {SetupClick (); // Alternatively, save the option to localsteas ['userchoice'] = 'click';}); $ ('# M') (SetupMouseover () {//} SetupMouseover (); // Alternatively, the option to use local storage ['userchoose'] = 'mouseover';};    

No comments:

Post a Comment