I am trying to change the id
of an element.
It works the first time, but not the second time.
The HTML is:
<span id="1">trying to change the id after multiple clic</span>
The Jquery is:
jQuery( "#1").click(function() {
$("#1").text("we change the id to 2");
jQuery("#1").attr("id","2")
console.log('id 1 clicked');
});
jQuery( "#2").click(function() {
// it nevers goes there
$("#2").text("we change the id to 3");
jQuery("#2").attr("id","3")
console.log('id 2 clicked');
});
here is the jsfiddle:
Thanks all for you help