效果如上。
reset是在页面都加载完毕后后添加的。通过prepend 函数将其插入到“ShowXXXentires”的前面。
code大致如下:
function add_reset_button(){
var reset_btn = '<button id="reset">reset</button>';
//$('#reset').bind('click', reset_footer_selection); // if it is here, not work
$('#my_datatable_length').prepend(reset_btn);
$('#reset').bind('click', reset_footer_selection);
}
function reset_footer_selection(){
alert('lalala');
}
结果: alert弹出
但如果将绑定click函数的语句提前到将其插入到页面的语句之前,那么alert是不工作的。