当前位置: 移动技术网 > IT编程>网页制作>CSS > HTML 练习on方法

HTML 练习on方法

2019年03月16日  | 移动技术网IT编程  | 我要评论
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>title</title>
    <script src="jquery-3.3.1.min.js"></script>
</head>
<body>
<ul>
    <li>111</li>
    <li>222</li>
    <li>333</li>
    <li>444</li>
</ul>
<input type="button" value="+" onclick="add()">
<script>
    $("ul").on("click", "li", function(){
        alert(888)
    })

    function add(){
        $("ul").append("<li>555</li>")
    }
</script>
</body>
</html>

on方法,传递参数

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>title</title>
    <script src="jquery-3.3.1.min.js"></script>
</head>
<body>
<p>hello p</p>
</body>
<script>
    function myhandler(e){
        alert(e.data.foo)
    }
    $("p").on("click", {foo: "klvchen"}, myhandler)
</script>
</html>

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网