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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:47:27+00:00 2026-06-12T19:47:27+00:00

I maintain (but didn’t develop) ASP site that has a comments form on its

  • 0

I maintain (but didn’t develop) ASP site that has a comments form on its blog pages.
When a comment is added, the page shows a new div styled with the class “comments-wrap”. If there is no comments yet, that div won’t appear at all. It doesn’t us an ID because there may end up being multiple comments on the page.

I want to add a new div to the page(s) that is empty (maybe using a &nbsp or the style display:none) unless the a script detects the presence of the “comments-wrap” class.

For example’s sake, lets call the new div . I’d like it to be present on the page all of the time (eg.  ), but the space changes to “Previous Comments” when the “comments-wrap” class is detected on the page.

So far I have:

<script>
function myFunction() {
if ($(".comments-wrap")[0]) { 
document.getElementById("comments-previous").innerHTML="Previous Comments";
}
}
}
</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-12T19:47:28+00:00Added an answer on June 12, 2026 at 7:47 pm

    If you are using jquery use .length to find the number of elements currently matched

    <script>
       $(document).ready(function(){
           if ($(".comments-wrap").length) { 
              $("#comments-previous").html('Previous Comments');
           }
       });
    </script> 
    

    Edit

    <!DOCTYPE html>
    <html>
    <head>
    <title>Untitled</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
    
    <script>
    $(document).ready(function(){
        if ($(".comments-wrap").length) { 
            $("#comments-previous").html('Previous Comments');
        }
    });
    </script> 
    </head>
    <body>
     <div class="comments-wrap"></div>
     <div id="comments-previous"></div>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I find R documentation to be important but also time-consuming to create/maintain. Has anyone
I have a table that has worked correctly for many years, but recently the
I have to maintain an application that has a lot of columns that are
I maintain an application that has a .aspx page that loads on image from
Updating an old piece of software but in order to maintain backward compatibility I
Does file_get_contents maintain line breaks? I thought it did but I have tried this:
I want to have one Drupal copy to maintain, but a lot of sites
Calling image = Image.open(data) image.thumbnail((36,36), Image.NEAREST) will maintain the aspect ratio. But I need
I maintain an applet that helps users to upload photos to our service. The
I'm doing a school project about maintaining a personal Database. but my tutors didn't

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.