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