I have a <select>
element which I need to track using change().
jQuery('.dropdown').change(function(){
yada, yada
});
Works perfectly on already created elements. However, if I dynamically create the <select>
, it (obviously) doesn't work. Now, I'm stuck with jQuery 1.3.2 (long story), so if I use something like:
jQuery('.dropdown').live('change', function(){
yada, yada
});
doesn't work.
So, any ideas? How can I make this work with dynamically created elements?
This works:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Test</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(function() {
$('select').live('change', function(){
alert(this.value);
});
});
</script>
</head>
<body>
<form>
<p>
<select name="numeros">
<option value="0">cero</option>
<option value="1">uno</option>
<option value="2">dos</option>
</select>
</p>
</form>
</body>
</html>