$(document).on("change","#pageSize_out",function(){ less
if($("#page_out").val()!=0){ this
$("#pageSize").val($(this).val()); spa
} code
}) ;orm
注意:ci
As this answers receives a lot of attention, here are two supplementary advises :element
1) When it's possible, try to bind the event listener to the most precise element, to avoid useless event handling.it
That is, if you're adding an element of class b
to an existing element of id a
, then don't useio
$(document.body).on('click', '#a .b', function(){
but useevent
$('#a').on('click', '.b', function(){
2) Be careful, when you add an element with an id, to ensure you're not adding it twice. Not only is it "illegal" in HTML to have two elements with the same id but it breaks a lot of things. For example a selector "#c"
would retrieve only one element with this id.
簡單來講就是要明確父子關係,不要直接用document,除非子元素就是加在document下