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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:16:51+00:00 2026-06-11T18:16:51+00:00

My Javascript <script type=’text/javascript’> //<![CDATA[ function showAnswer() { alert(‘Answer’); var els = document.getElementsByClassName(‘answer’); if

  • 0

My Javascript

<script type='text/javascript'>
 //<![CDATA[
function showAnswer()
{
  alert('Answer');
  var els = document.getElementsByClassName('answer');
if (els.style.display != 'inline')
    els.style.display = 'inline';
} 
}

     //]]>
</script>

Where answer is a class name on page for p tag which is initially hidden by the following code:

 .answer { display:none; }

This is code for calling showAnswer which is not working…

 <div class='show_hide_answers'>
        <a href='#' onclick='showAnswer();'>Show Answer</a>
 </div>

Clicking on Show answer does nothing. Even it is not showing alert means javascript is not running. Please help me solve this problem.
See this page for more details (this is the code for this page)

http://www.technodoze.com/2012/09/the-idea-that-light-is-em-wave-was.html

Thanks in advance if you could help me plz…

Note: I have tried all these:

<a href='#' onclick='showAnswer()'>Show Answer</a>

<a href='#' onclick='javascript:showAnswer();'>Show Answer</a>

<a href='#' onclick='javascript:return showAnswer();'>Show Answer</a>

No one is working.

  • 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-11T18:16:52+00:00Added an answer on June 11, 2026 at 6:16 pm

    getElementsByClassName returns a NodeList instead of a single Node. Thus, you need to iterate over the resulting NodeList:

    var els = document.getElementsByClassName('answer');
    for (var i = 0; i < els.length; i++) {
      var el = eles[i];
      if (el.style.display != 'inline') {
        el.style.display = 'inline';
      }
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<script type=text/javascript> var timeout; function doAjaxFunc(){ alert(called); $.ajax({ type: POST, url: searchSuggest.php, data: dataString,
I have this code: <script type=text/javascript> function js() { var getJs = document.getElementById(jogo); if
< script type = text/javascript > $(function() { var oAllLinksTable = $(#mydatatable).dataTable({ bProcessing: false,
Look this code: <script type = text/javascript> function mouseClick (container) { container.appendChild (document.createTextNode (Can
Below is the code for my YWA wrapper var astr_ywascript = (document.createElement(script).type = text/javascript).src
<script type=text/javascript> if (typeof jQuery == 'undefined') { var script = document.createElement('script'); script.type =
var script = document.createElement( 'script' ); script.type = 'text/javascript'; script.src = 'http://www.mydomain.com/bleh.php'; script.id =
The code is like this: var script = document.createElement('script'); //script.type = 'text/javascript'; // do
<div id="myLuckyPost"> </div> <script type="text/javascript"> function showLucky(root){ var feed = root.feed; var entries =
<script type=text/javascript> function testing() { $.ajax({ type: POST, url: testing.php, data: call=+$(#abc).val(), success: function(msg){

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.