I have a code similar to this, where I assign a function to the click even that change the style
$(".style1, .style2", "#section").click(function () {
changeStyle($(this));
});
it might happens that the item change from style1 to style2, so the item should be still clickable, but the actions doesn't take effect. Seems that the item list $(".style1, .style2", "#section") is created on load and is not updated when i the stile is changed to include new elements.
I have tried to put the pasted code into a function and call it at the end of the function changeStyle
, but this adds another trigger, so when I click in other items with style1
or style2
, the actions trigger 2, 3, 4, ... times. And I just one to trigger it once.
How can I solve it?
Thanks for your help.