here is my code:
$("input[name=myText]").replaceWith("<input name='myText' type='text'/>" +
"Select a number: <select name='numberSelect' id='numberSelect'>" +
"<option value=''></option>" +
"<option value='.5'>.5</option>" +
"<option value='1'>1</option>" +
"<option value='1.5'>1.5</option>" +
"<option value='2'>2</option>" +
"</select>"
);
$("#numberSelect").change(function () { alert('hello') });
I just can’t get the event of selecting an item in the dropdown to fire.
Any ideas? Thanks!
Try using $.live http://api.jquery.com/live/
UPDATE
As mentioned below by abraham, as of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers. So the new code should be :