JQuery的bind(“click",function())与click(function(e))有什么区别?
cyi59 2015-03-05 04:58:19 JQuery刚开始看两三天,看到了bind()觉得有一点困惑
所以如果我的问题太弱智请不要太鄙视_(:з」∠)_
bind()是将某一个事件绑在元素上,而书上在讲bind()之前的写法[比如click(function(e))]与之有什么不同呢?
举个栗子-以click为例
html里是这样定义的:
<button type="button" id="logIn">Go!</button>
//click()
$("#logIn").click(function(e) {
var test="<p id='test'>TEST</p>";
$("body").append(test);
$("#test").show("fast");
});
//bind()
$(function() {
$("#logIn").bind("click",function() {
var test="<p id='test'>TEST</p>";
$("body").append(test);
$("#test").show("fast");
})
})
从效果上来看似乎是一样的?
两者有什么区别吗?
谢谢大神们!