jquery change doesn't work on select

html, jquery, select

Solution

You need to wrap your code inside DOM ready handler `$(document).ready(function() {...});` or shorter form `$(function() {...});` to make sure all of your DOM elements have been loaded properly before executing your jQuery code.

$(function() {
    $('#numbers').change(function(){
        alert('other value');
    });
});

Fiddle Demo

Problem

Why doesn't this work? I'm not sure what I'm doing wrong. I'm certain that jquery is working on the page. Can anyone help me? Thanks in advance ``` <!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="styles/derweco.css"/> <script type="text/javascript" src="scripts/jquery-2.1.0.js"></script> <script type="text/javascript"> $('#numbers').change(function(){ alert('other value'); }); </script> </head> <body> <div id="home"> <select id="numbers"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> </div> </body> </html> ```

Original source