首页
IT
登录
6mi
u
盘
搜
搜 索
IT
jquery事件命名空间
jquery事件命名空间
xiaoxiao
2021-03-28
41
<!DOCTYPE html>
<
html
lang
=
"en"
>
<
head
>
<
meta
charset
=
"UTF-8"
>
<
title
>
jquery事件命名空间
</
title
>
<
script
src
=
"js/jquery.min.js"
>
</
script
>
<
style
>
.btn
{
height
:
50
px
;
width
:
50
px
;
border
:
1
px solid
#000
;
margin
:
10
px
;
}
</
style
>
</
head
>
<
body
>
<
div
class
=
"wrap"
>
<
input
type
=
"button"
value
=
"按钮"
class
=
"btn"
>
</
div
>
<
script
>
$(
function
()
{
$(
".btn"
).on(
"click.aaa"
,
function
()
{
//绑定第一个点击事件
alert(
11
); }); $(
".btn"
).on(
"click.bbb"
,
function
()
{
//绑定第二个点击事件
alert(
22
); $(
".btn"
).off(
"click.aaa"
);
//去除第一个点击事件
});
/*$(".btn").one("click.aaa",function () { //绑定的第一个点击事件,可以采用one()一次执行方法 alert(11); });*/
});
</
script
>
</
body
>
</
html
>
转载请注明原文地址: https://ju.6miu.com/read-664664.html
技术
最新回复
(
0
)