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
Release: 2016-05-16 18:05:44
Original
1182 people have browsed it

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代码。
    Related labels:
    source:php.cn
    Statement of this Website
    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
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template