jquery如何綁定事件

愛看星星的稻草人
124
2021-05-21 13:11:52
欄目: 編程語言

jquery中綁定事件的方法有:1.使用on()函數(shù)綁定事件;2.使用bind()函數(shù)綁定事件;3.使用live()函數(shù)綁定事件;4.使用delegate()函數(shù)綁定事件;


jquery如何綁定事件


jquery中綁定事件的方法有以下幾種

1.使用on()函數(shù)綁定事件


$("#id").on("click",function(){

alert("");

})


2.使用bind()函數(shù)綁定事件


$("#id").bind("click",function(){

alert("");

})


3.使用live()函數(shù)綁定事件


$("#id").live("click",function(){

alert("");

})


4.使用delegate()函數(shù)綁定事件


$("#id").delegate("button","click",function(){

alert("");

})



0