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 6862323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:38:52+00:00 2026-05-27T02:38:52+00:00

I need help with this code if someone is willing to help. I cannot

  • 0

I need help with this code if someone is willing to help. I cannot get the 2 getElementById functions to work and I am a beginner so I am sure it is something simple but I have not been able to fix it. I need to click on the text to change the font. Any help in the right direction will be greatly apprecited. Please check the code below.

<?xml version = "1.0" encoding = "utf-8"?>
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">

<head>
        <title>Solution Page 486 Exercise 12.7</title>
   <style type = "text/css">
           .option { color: darkblue }
           .graybg { background-color: #aaaaaa }
           .whitebg { background-color: #ffffff }
           .sans { font-family: sans-serif }
           .serif { font-family: serif }
        </style>
<script type = "text/javascript">
           function bodyClass(color)
          {
              document.body.className = color;
          }

        </script>
     </head>

     <body>
        <div id = "main">Click on Options Listed Below to see how they modify this page.<br ><br >
          <div>Options:
          <div onclick = "bodyClass('graybg');"
                class = "option">Gray background</div>
              <div onclick = "bodyClass('whitebg');"
                class = "option">White background</div>
             <div onclick = "document.getElementById("  class
                 = "option" classname ="sans" ? main?).>Sans-serif text</div>
             <div onclick = "document.getElementById("  class
                 = "option" classname ="serif" ? main?).>Serif text</div></div></div>
     </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-05-27T02:38:53+00:00Added an answer on May 27, 2026 at 2:38 am

    Do not write JavaScript in a string assigned to an ‘onclick’ property. Write it in a function in a tag and assign the function,here is the code:

    <body>
    ...
    <div id='an_id'> <!-- doesn't have to be a div, any element is OK -->
    ...
    <script type='text/JavaScript'>
        var some_elem = document.getElementById( 'an_id' );
            some_elem.onclick = my_func; // no parens, no quotes!
    
        function my_func() {
            // your code goes here
            // in here, 'this' refers to the element that got the click
        }
    </script>
    
    </body>
    

    Hope this will help.

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

Sidebar

Related Questions

Sorry to bother again, but I really need help transforming this Python2 code into
I need help on this following aspx code aspx Code: <asp:Label ID =lblName runat
I need some help understanding this bit of code pre { white-space: pre; white-space:
I need help to use jConfirm with this existing code (php & Jquery &
i need help with disk_total_space function.. i have this on my code <?php $sql=select
I really need help on this one. I am having a simple login form
I need help with this code, it doesent insert the values to my database.
I need some help understanding what's happening here. This code is from a models/log.py
Can someone please help with converting this code to plain JS: $(document).ready(function() { $(textarea).bind(keydown,
Could someone tell me what is wrong with this code so doxygen cannot handle?

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.