Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Dec 2011
    Posts
    64
    Thanks
    19
    Thanked 0 Times in 0 Posts

    delete wrapping HTML tag around content with Javascript?

    Assume I have a HTML code like:

    <span>AABBCC</span>

    How can I get rid of this wrapping HTML tag without deleting the content inside the tag?

    So the Javscript should look like similar to (does not work):

    $("<span>AABBCC</span>").removestrings("<span>","</span>");

    Afterwards

    AABBCC

    should stay alive

  2. #2
    Master Coder sunfighter's Avatar
    Join Date
    Jan 2011
    Location
    Washington
    Posts
    6,275
    Thanks
    30
    Thanked 863 Times in 861 Posts
    Maybe this:
    Code:
    <!doctype html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title></title>
    <style type="text/css">
    span{color:green;}
    </style>
    </head>
    <body>
    <span>AABCC</span>
    <span>AABBCC</span>
    <span>AABBC</span>
    
    <script src="//code.jquery.com/jquery-1.10.2.js"></script>
    <script>
    $( "span:contains(AABBCC)" ).contents().unwrap();
    </script>
    </body>
    </html>
    Evolution - The non-random survival of random variants.
    Physics is actually atoms trying to understand themselves.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •