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
    41
    Thanks
    14
    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
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,225
    Thanks
    23
    Thanked 606 Times in 605 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.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."


  •  

    Posting Permissions

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