$("b").bind("contextmenu",function(e){
thiselementselected = e.target
$("#add").bind("click",function(e){
thiselementselected.css("font-color", "red");
return false
});
$("#remove").bind("click",function(e){
thiselementselected.css("font-color", "");
return false
});
return false
});
when i click on a b> element and click 'add', it will make the font color red.
I do this for several b> elements.
then when i click on one of them and click remove, it will remove colors from ALL b> elements... its supposed to remove from on开发者_开发问答ly one given element b>
when i click on another b> and click 'add', now all previously selected b> elements will turn red !
i dont understand why this is happening....
try unbinding the click event on #add and #remove before you bind them to a new element. Otherwise you're just adding on to the event queue.
精彩评论