How to use ID selector after jQuery html()
- by user555617
It's amazing to try to understand why the function alert("hello") is not generated after clicking more than once... There is some method to do this function is executed?
Note that doesn't work after update using html() involving id "press" in button.
Any idea? See: http://jsbin.com/atuqu3
JavaScript:
$(document).ready(function (){
$("#press").click(function() {
$("#relation-states").html('<select id="state" name="state"> <option value="Texas">Texas</option> </select><button id="press" type="button" title="" aria-haspopup="true" style="width: 175px;"><span>Select an item</span></button>');;
alert("hello");
});
});
HTML:
<div id="relation-states">
<select id="state" name="state">
<option value="New York">New York</option>
</select>
<button id="press" type="button" title="" aria-haspopup="true" style="width: 175px;"><span>Select an item</span></button>
</div>