Thursday, 19 September 2013

Change li class in javascript

Change li class in javascript

I want to change the class of the current li(list) which is selected
$('li.doBlokkeer').click(function(e) {
$(this).addClass('doDEBlokkeer').removeClass('doBlokkeer');
});
$('li.doDEBlokkeer').click(function(e) {
$(this).addClass('doBlokkeer').removeClass('doDEBlokkeer');
});
so if a current li is selected its class need to be changed (it needs to
have doDEBlokkeer). The above code works.. The problem is that this only
works once for each LI item..
when I click on li.doBlokkeer the class changes which is good, but when I
press the same current li again, it calls the same function li.doBlokkeer
instead of li.doDEBlokkeer function (despite the css class) . I tried so
much stuff but i really can't find any solution. can you guys help me out?
I have been searching for a solution for more then 14 hours, so frustrated
right now...

No comments:

Post a Comment