Skip to content Skip to sidebar Skip to footer

Toggle Between Two Different Click Events Using Jquery?

So...I am having a bit of trouble trying to create a toggle effect with jQuery that allows for the alternation between two different click events on an li tag.I want the li tag to

Solution 1:

Check for its current state before proceeding.

Also, <li>'s must have <ul> or <ol> as a parent element.

$('li').on('click', function(e){
  e.preventDefault();
  if($(this).css('opacity') != 1){
    $(this).fadeTo(300,1);
  }else{
    $(this).fadeTo(300,0.5);
  }
});

Demo: http://jsfiddle.net/PZ96m/

Post a Comment for "Toggle Between Two Different Click Events Using Jquery?"