开发者

How to change for select change in ajax generated select list

开发者 https://www.devze.com 2023-02-13 16:49 出处:网络
I have <select id=\"someid\"></select> I then click something and jquery.ajax generates new div and attach .html(data) to #someid select. How do I check for change in select?

I have <select id="someid"></select>

I then click something and jquery.ajax generates new div and attach .html(data) to #someid select. How do I check for change in select?

The reason why I am asking is that I start with empty selects and load them with data related to one record.

There are two selects, select1 and select2. I generate select1 just once and based on selected option from开发者_高级运维 select1 then I generate select2. I need to track if select1 has not been changed and whether I need to regenerate select2. Currently it doesnt do anything $("#select1").change(alert('test')) starts immediately after running the page but wont do anything after another change. It just wont run.

Is this possible?

Thanks.


If ive read the question right, this is very easy using .change()

$('select#someid').live('change', function() {
  // you code
});
0

精彩评论

暂无评论...
验证码 换一张
取 消