using jquery, if i need to capture dropdown change event, do i need livequery plugin?

StackOverflow https://stackoverflow.com/questions/7223618

سؤال

I want to have some code run when i change the selection of a dropdown. i see the livequery plugin states that this is needed to support as some browsers don't do it out of the box

Do I really need livequery to capture onchange event of a dropdown that i create dynamically or does the regular live syntax work in all browsers?

هل كانت مفيدة؟

المحلول

live takes advantage of event bubling mechanism so we can attach event handlers to elements which are created dynamically also, it will work as expected since it attaches event to the document element and listens to them. But I believe change event is not bubbled upto the dom tree so it may not work.

نصائح أخرى

from this page, it looks like you need livequery for it to work in IE

No. You should be able to use just the standard jquery api.

for the dynamic elemenets use .live('change', function to capture the event.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top