zoukankan      html  css  js  c++  java
  • jQuery学习总结05-事件

    1.事件的发生

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
        <input id="t1" type="text" />
        <input id="a1" type="button" value="添加" />
    
        <ul id="u1">
            <li>1</li>
            <li>2</li>
        </ul>
    <script src="jquery-1.12.4.js"></script>
        <script>
            $('#a1').click(function () {
                var v = $('#t1').val();
                var temp = "<li>" + v + "</li>";
                $('#u1').append(temp);
            });
    
    //        $('ul li').click(function () {
    //            var v = $(this).text();
    //            alert(v);
    //        })
    
    //        $('ul li').bind('click',function () {
    //            var v = $(this).text();
    //            alert(v);
    //        })
    
    //        $('ul li').on('click', function () {
    //            var v = $(this).text();
    //            alert(v);
    //        })
    
           //以上对于新增加的标签,都无法添加点击事件,只有如下可以
            $('ul').delegate('li','click',function () {
                var v = $(this).text();
                alert(v);
            })
    
        </script>
    </body>
    </html>    

     2.

  • 相关阅读:
    【转载】关于C#中动态加载AppDomain的问题
    poj2239
    poj2231
    poj2229
    poj2234
    poj2236
    前 路
    只含一个单词的句子
    做人准则
    改变人生的32句励志名言
  • 原文地址:https://www.cnblogs.com/it-q/p/9291273.html
Copyright © 2011-2022 走看看