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

  • SEARCH
  • Home
  • 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 9161295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:56:10+00:00 2026-06-17T13:56:10+00:00

So I was advised recently not to use document.write. But I can’t seem to

  • 0

So I was advised recently not to use document.write. But I can’t seem to figure out how to use DOM manipulation to make it document print on screen. This function works so that you hit the button enter the number of miles traveled by car and you get your carbon foot print. Only with document.write it overwrites the entire page after you click the button. I tried getElementbyId but it doesn’t seem to print anything so I know I’m probably not using it correctly. Any ideas on an alternative that will complete the function without overwriting the page would be much helpful>

Below is the code I have with just document.write, the one that overwrites the entire page:

<script>

    $(document).ready(function() {
        $(".button").click(function() {

            var myNumber = 19.2;
            var myAnswer = prompt ("How many miles did you travel?");
            document.write( " Your Carbon Foot print is:" + myAnswer * myNumber + "lbs" );

          });
      });
      </script>
  • 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-17T13:56:12+00:00Added an answer on June 17, 2026 at 1:56 pm

    DOM manipulation involves creating document elements and inserting them into the document tree. It’s something that should become second nature to you if you want to do extensive work with JS:

    - document.write(...
    + $("<span>").text(' Your Carbon Foot print ...').appendTo("body");
    

    You probably want to append the text to something else, but the above should have a similar affect and not overwrite the entire page.

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

Sidebar

Related Questions

Recently I use stringtemplate,I noticed StringTemplate can't support complex conditional,similar value>1 or value=menu etc.
It is generally advised not to use additional linux tools in a Perl code;
I was advised to use this code to make my method execute after a
Asked this question question recently and was advised to use the ' to.minutes5() '
I know it's not advised to go more then 1 level deep in nested
As a newbie, I have been advised to preferably use heredoc compared to too
I initially asked this on Superuser, but somebody advised me to repost here. I
I've been developing in PHP for a while now but only recently made the
A friend and developer I respect recently advised that I avoid using 'Includes' in
I was advised a while ago that is was common place to use std::vector

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.