JQuery event handler when select element is loaded

前端 未结 7 1720
清歌不尽
清歌不尽 2021-01-03 01:53

Is there an event handler to use in JQuery when a DOM select element has finished loading? This is what I want to achieve. It is working with other events e

7条回答
  •  孤城傲影
    2021-01-03 02:45

    If your select elements are dynamically loaded, why not add the event handler after you process the response?

    e.g. for ajax

    $.ajax({
      ...
      success: function(response) {
       //do stuff 
       //add the select elements from response to the DOM 
       //addMyEventHandlerForNewSelect();
    
       //or
    
       //select the new select elements from response
       //add event handling on selected new elements
      },
      ...
    });
    

提交回复
热议问题