首先介紹這兩個(gè)方法之前,我們常用的是click()方法
復(fù)制代碼 代碼如下:
$("a").click(function() {
alert("hello");
});
參數(shù):type,[data],function(eventObject)
例如:
復(fù)制代碼 代碼如下:
$("p").bind("click",function(){
alert("hello");
})
復(fù)制代碼 代碼如下:
var message = "how are you!";
$("p").bind("click",{msg:message},function(e){
alert(e.data.msg);
})
復(fù)制代碼 代碼如下:
<tr>
<td>Click me</td>
</tr>
$(".mytd").bind("click",function(){
alert("hello");
})
此時(shí)添加一個(gè)新的元素進(jìn)來
復(fù)制代碼 代碼如下:
$(".mytr").after("<tr><td>后加的</td></tr>");
復(fù)制代碼 代碼如下:
$(".mytd").live("click",function(){
alert("hello");
})
新聞熱點(diǎn)
疑難解答
圖片精選