Jquery event when <option> s is added or removed from <select>

Is there a jquery event when parameters are added or removed from a select control on an HTML page? I tried .change(), but it only fires when I click on option elements. That is, this does not work:

$(function() {
    $('#select').change(function() {
            alert('hello world');
    })
});

Thank:).

+5
source share
3 answers

You need a plugin to check if HTML is added or removed from the DOM. livequery is a plugin http://docs.jquery.com/Plugins/livequery

+1
source

: $( "# selector" ). trigger ( "change" ); .

+2

I don't think a standard event change()will do it for you. What you want to do is a function that runs when a new option is added to the selection field. How do you currently add options to this checkbox?

+1
source

All Articles