Jquery remove form tag, not content

后端 未结 6 605
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-17 01:33

Hello i need to remove a form tag but non the content:

not remove this only the form tag
相关标签:
6条回答
  • 2020-12-17 01:36
    $('.element').replaceWith(function() {
    

    return $(this).html(); });

    This is wrong....

    $form = $('#form');
    

    $form.replaceWith($form.html());

    This one is correct...

    0 讨论(0)
  • 2020-12-17 01:39

    add an id or class to your div

    e.g.

    <form id="form">
    <div class="wrapper"> not remove this only the form tag</div></form>
    

    Then

    $(".wrapper").unwrap();
    
    0 讨论(0)
  • 2020-12-17 01:40

    if it's xml (as pages generated by dotNet), just remove the form node

    0 讨论(0)
  • 2020-12-17 01:46

    In case you have many elements that need to be modified:

    $('.element').replaceWith(function() {
      return $(this).html();
    });
    

    jsFiddle: http://jsfiddle.net/calvintennant/mdrHb/

    0 讨论(0)
  • 2020-12-17 01:48
    $form = $('#form');
    $form.replaceWith($form.html());
    

    Should do what you need.

    0 讨论(0)
  • 2020-12-17 02:00

    When you remove the form tag from the DOM, all of its children elements go right with it. The only way you could achieve what you are asking is to pull all of the form tag's immediate children and append them to some other node in the DOM to keep them from disappearing from the page

    0 讨论(0)
提交回复
热议问题