i have the following button with id "openWindow"
<button id="openWindow">Open Window on Click</button>
and I have this jquery code, which send an alert "Open" and change the button id to "closeWindow"
$( "#openWindow" ).click(function() {
alert("Open");
$( "#openWindow" ).attr("id", "closeWindow");
})
$( "#closeWindow" ).click(function() {
alert("Close");
});
On first click:
- Alert "open" appears and the id changed to "closeWindow"
On second click
- the alert "Close" will not appear.
Can anybody tells me why?