tags:

views:

94

answers:

3

Hi,

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?

A: 

AFAIK, onchange event is not supported by live() try to use livequery plugin

Soufiane Hassou
That's not true, I just tested jquery-1.3.2.min.js and it works
coma
A: 

This works:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
 <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"&gt;&lt;/script&gt;
  <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>
coma
A: 

With jQuery 1.4.2 $('select').live('change', function(){ works with FF, Safari, Opera, but not for IE

Axel