Jquery selector not finding elements when loading ajax
When I download <select id="myid" >Element using ajax from my server. This selector does not work. But when I put this code in html and not Load Ajax, this selector works well ...
$('#myid').change(function(){
alert('OK!');
});
<select id="myid" >
<option>1</option>
<option>2</option>
<option>3</option>
</select>
How to fix this error?
Event handlers are bound only to the currently selected elements; they must exist on the page when your code is binding to the event.
Delegated events have the advantage that they can handle events from descendant elements that will be added to the document later.
How do you upload content using ajax.
. .on() .
$(document).on('change','#myid', function(){
alert('OK!');
});
document .