I am encountering an issue with the "click" action on a newly created element through a jQuery function, as it is not functioning properly.
To demonstrate this problem, I have set up a JSFiddle at the following link (JSFiddle), however, please note that the Ajax request may not work within JSFiddle environment.
The scenario involves two buttons:
<input type="button" onclick="invia('SIC-034031','', 's');" value="AGGIUNGI" style="height: 20px; width: 110px; background-color: #A5EFC5 ; color: #000000; font-family: Arial,Helvetica,sans-serif; font-size: 12px; background-repeat: no-repeat; background-position: left center;" id="iscriviSIC-034031" class="pulsanteIscrizioni" name="xaggiorna"/>
<input type="button" onclick="invia('SIC-034031','R', 's');" value="RISERVA" style="height: 20px; width: 110px; background-color: #F00000; color: #FFFFFF; font-family: Arial,Helvetica,sans-serif; font-size: 12px; background-repeat: no-repeat; background-position: left center;" id="iscriviRSIC-034031" class="pulsanteIscrizioni" name="xaggiorna"/>
Upon initiating the ajax function for the first time, the response from button one is:
OK;I;SIC-034031
Button two's role is solely for deletion. Button one handles creation.
<input id="iscriviSIC-034031" class="pulsanteIscrizioni" type="button" name="xaggiorna" style="height: 20px; width: 110px; background-color: #03F; color: #FFF; font-family: Arial,Helvetica,sans-serif; font-size: 12px;" value="TOGLI" onclick="invia('SIC-034031','');">
Upon clicking this new button, the ajax function returns:
OK;C;SIC-034031;;
At this point, button one disappears and button two reappears. However, the issue lies in the fact that when I click on the first button, everything functions correctly, but clicking on the second button does not yield desired results.
If you could offer assistance in identifying the root cause of this problem, it would be greatly appreciated.
Thank you ;)