美文网首页
js bind 的用法

js bind 的用法

作者: duJing | 来源:发表于2016-12-13 16:05 被阅读85次

html

<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script language="javascript" src="bind.js"></script>
<script language="javascript" src="../jquery-2.1.3.min.js"></script>
</head>
<body>

<input type="button" id="btn" value="点击我" onclick="del();" >
</body>
</html>


js

function del(){
alert("aaa");
$("#btn").attr("onclick","");
$("#btn").bind("click",function(){
bbb();
})
}

function bbb(){
alert("123456")
$("#btn").unbind("click");
$("#btn").bind("click",function(){
$("#btn").attr("click",function(){
ccc()
});
})
}

function ccc(){
alert("8888")
}

相关文章

网友评论

      本文标题:js bind 的用法

      本文链接:https://www.haomeiwen.com/subject/qeyemttx.html