Can someone please tell me where the mistake is, I just can't see it. 'e1 has changed' should be logged to the console when the select changes.
html:
<select name="e1" id="e1">
<option value="1">1</option>
<option value="2">2</option>
</select>
js:
$('#e1').change(function() {
console.log('e1 has changed');
});
jquery is definitely working since I'm successfully "getting" server data for other elements.
This code
$('#e1').change(function() {
console.log('e1 has changed');
});
is likely not in your document ready handler, and is therefore being run before your dom element e1
is ready. You can create a document ready handler, which will run when your dom elements are ready, like this
$(function() {
$('#e1').change(function() {
console.log('e1 has changed');
});
});
Works for me. Here is the jsFiddle code -
http://jsfiddle.net/CC5P6/
$(document).ready(function() {
$('#e1').change(function() {
alert('e1 has changed');
});
});
I you haven't done so already you should wrap your code in the $(document).ready(
:
$(document).ready(function() {
$('#e1').change(function() {
console.log('e1 has changed');
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With