.bind和其他事件之间的区别 [英] Difference between .bind and other events

查看:53
本文介绍了.bind和其他事件之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下几行代码有什么区别,或者它们只是两种写同一件事的不同方式:

What is the difference between the following lines of code, or are they just 2 different ways to write the same thing:

$("p").click(function() { some code here });

$("p").bind("click", function(){ some other code here });

我是否过度简化了?因为如果您想绑定多个事件,则可以将事件链接在一起,对吗?

Am I over simplifying this? Because if you wanted to bind more than one event you could just chain the events, correct?

推荐答案

它还允许您将相同的匿名方法绑定到多个事件,例如:

It also allows you to bind the same anonymous method to multiple events like:

$("p").bind("click dblclick mouseover mouseout", function(){ some other code here });

这篇关于.bind和其他事件之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆