Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9184767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:08:04+00:00 2026-06-17T19:08:04+00:00

I am wondering how I would remove code that appears after I select a

  • 0

I am wondering how I would remove code that appears after I select a certain Radio Button. I have got it to generate but when I remove it the whole body disappears so, I would need to only remove the fragment.

<head>
    <style>
        input, label {
            line-height: 1.5em;
        }
    </style>
    <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>

<body>
    <form>
        <div>
            <input type="radio" name="modtype" value="My Mods" id="mymods">
            <label for="orange">My Mods</label>
        </div>
        <div>
            <input type="radio" name="modtype" value="Group Mods" id="groupmods">
            <label for="apple">Group Mods</label>
        </div>
        <div>
            <input type="radio" name="modtype" value="Individual Mods" id="individualmods">
            <label for="banana">Individual Mods</label>
        </div>
        <div id="modtype"></div>
    </form>
    <script>
        $("input").on("click", function() {
            $("#modtype").html($("input:checked").val() + " is selected! - Now Choose Mod! :)");
        });
    </script>
    <script>
        var appended = $('<div />').text('YOYOY');
        var fragment = create('<div>Hello!</div><p>...</p>');

        appended.id = 'appended';

        $('input:radio[name="modtype"]').change(

        function() {
            if ($(this).val() == 'My Mods') {
                document.body.insertBefore(fragment, document.body.childNodes[0]);
            } else {
                document.body.remove(fragment);
            }
        });

        function create(htmlStr) {
var frag = document.createDocumentFragment(),
    temp = document.createElement('div');
temp.innerHTML = htmlStr;
while (temp.firstChild) {
    frag.appendChild(temp.firstChild);
}
return frag;
}
    </script>
</body>

 </html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:08:05+00:00Added an answer on June 17, 2026 at 7:08 pm

    This will fix your code, I have tested it here: http://jsfiddle.net/gJk7J/

    Simply change:
    document.body.remove(fragment);
    To:
    if(fragment.parentNode)fragment.parentNode.remove(fragment);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm wondering what would be best to do. Right now I have running a
So I am wondering what would cause it so that all events for the
i was wondering what would be the best way to code a browser plugin
I have divs that are initially closed. The code below then controls the opening/closing:
I would like to point out that I'm not really a developer, but rather
I'm wondering what Data Structure people would recommend to do the following. I have
I have the following html code: (that gets loaded via ajax into a div)
I have a script that I'm working on that is intended to remove the
I have got a list of elements that im trying to delete using the
I am wondering how I would remove the vowels from a word on a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.