views:

62

answers:

2
$("li").hover(
function () {
    // do x
},
function () {
    // do y
});

.. thats for hover, how would I do the same for click toggle, i.e do x on click and y on second click?

Manythanks

+4  A: 
$('li').toggle(function() {
 alert(1)
}, function() {
 alert(2);
});
meder
+3  A: 

$.toggle() will take any number of functions. Here it is with two:

$("li").toggle(
  function() {
    // do x
  },
  function() {
    // do y
  }
);
Jonathan Sampson