码迷,mamicode.com
首页 > 编程语言 > 详细

python :添加的内容具有之前的功能用delegate绑定事件

时间:2016-12-09 00:17:52      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:remove   splay   span   ext   cte   ted   rem   lock   title   

技术分享
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>Title</title>
    <meta charset="UTF-8"/>
</head>
<body>
<input id="a1" type="text"/>
<input id="a2" type="button" value="添加"/>
<input id=‘b‘ type="button" value="删除"/>
<ui id="u">
    <li>1</li>
    <li>2</li>
</ui>
<script src="jquery-1.12.4.js"></script>
<script>
//delegate比较重要---委托
    $(‘#a2‘).click(function () {
        var t = $(‘#a1‘).val()
        var l = ‘<li>‘ + t + ‘</li>‘
        $(‘#u‘).append(l)
    })

    $(‘ui‘).delegate(‘li‘, ‘click‘, function () {
        var a = $(this).text();
        alert(a);
    })

     $(‘#b‘).click(function () {
         var index = $(‘#a1‘).val()
        $(‘#u li‘).eq(index).remove()

    })
</script>
</body>
</html>
添加-删除功能delegate事件

 

python :添加的内容具有之前的功能用delegate绑定事件

标签:remove   splay   span   ext   cte   ted   rem   lock   title   

原文地址:http://www.cnblogs.com/xuehuahongmei/p/6146766.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!