I use this code to change id to an <input type="button" id="avvia_timer" value="AVVIA" />
:
$("#avvia_timer").click(function() {
$(this).val("INIZIA");
$(this).attr("id", "inizia_timer");
});
I changed id with $(this).attr("id", "inizia_timer");
Then I want to show 'id' with an alert but doing click on the element with the new id
$("#inizia_timer").click(function() {
alert($(this).attr("id"));
});
this doesn't work. Why? How can I fix?
Html code:
<div id="timer">
<input type="button" id="avvia_timer" value="AVVIA" />
<input type="button" id="stop_timer" value="FERMA" />
<span id="tempo_timer">Timer</span>
</div>