jquery怎么用两个事件启动一个函数?
phpcn_u238
phpcn_u238 2017-03-06 14:21:15
0
2
870

像这样。加载完成和点击都可以触发同一个函数

$(function(){ $("button").click(function(){ alert("ok"); }); });

当然这个是不能实现。求大神改改

phpcn_u238
phpcn_u238

reply all (2)
数据分析师

How does jquery start a function with two events? -PHP Chinese website Q&A-How does jquery start a function with two events? -PHP Chinese website Q&A

Let’s take a look and learn.

    阿神

    不用匿名函数就可以的:

    function finish(){ alert("ok"); } $(function(){ $("button").click(finish); finish(); });
      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!