Home >Web Front-end >JS Tutorial >jquery adds and removes html implementation code at will_jquery

jquery adds and removes html implementation code at will_jquery

WBOY
WBOYOriginal
2016-05-16 18:05:441202browse

html代码:

复制代码 代码如下:


  • plain

  • special

  • plain



script代码:
复制代码 代码如下:

function addRemoveItemNS() {
var $newLi = $('
  • special and new
  • ');
    $('#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代码。
    Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn