<p id="one">
One!
</p>
<p id="two">
Two!
</p>
<p id="three">
Three!
</p>
<p id="four">
Four!
</p>
<p id="five">
Five!
</p>
function showName(name){
console.log("name="+name);
}
$("#one").click(function(){
var name="chengzhen";
showName(name);
});
$("#two").click(function(){
var name="libai";
showName(name);
});
$("#three").click(showName);
$("#four").click({name:"chengzhen",age:25,height:180},function(e){
console.log(e.data);
});
/* click 事件也有下面这种写法 .click([eventData],handler)*/
$("#five").click({name:"chengzhen",age:25,height:180},function(e){
showInfo(e.data);
});
function showInfo(data)
{
console.info(data);
}
其实上面第一种写法,清楚一点。