您的位置:首页 > Web前端 > JQuery

jquery随意添加移除html的实现代码

2011-06-21 23:15 701 查看
function addRemoveItemNS() { var $newLi = $('<li class="special">special and new <button class="addone">I am new</button> <button class="removeme">remove me</button></li>'); $('#list3 li.special') .find('button.addone') .unbind('click.addit') .bind('click.addit', function() { $(this).parent().after($newLi); addRemoveItemNS(); }) .end() .find('button.removeme') .unbind('click.removeit') .bind('click.removeit', function() { $(this).parent().remove(); }); } $(document).ready(function() { addRemoveItemNS(); });
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  添加移除 html