像这样。加载完成和点击都可以触发同一个函数
$(function(){ $("button").click(function(){ alert("ok"); }); });
当然这个是不能实现。求大神改改
How does jquery use two events to start a function-PHP Chinese website Q&A-How does jquery use two events to start a function-PHP Chinese website Q&A
Just watch and learn.
不用匿名函数就可以的:
function finish(){ alert("ok"); } $(function(){ $("button").click(finish); finish(); });
How does jquery use two events to start a function-PHP Chinese website Q&A-How does jquery use two events to start a function-PHP Chinese website Q&A
Just watch and learn.
不用匿名函数就可以的: