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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:23:09+00:00 2026-06-05T10:23:09+00:00

I have a simple jquery script that shows and hides div block: <script type=text/javascript>’

  • 0

I have a simple jquery script that shows and hides div block:

<script type="text/javascript">'
    $(document).ready(function(){    
        $(".slidingDiv").hide();
        $('.show_hide').click(function(){
            $(".slidingDiv").slideToggle();
        }); 
    });
</script>

<a class="show_hide" href="#">Show/hide</a>
<div name="gohere" class="slidingDiv">
   ...
</div>

It’s working fine, but if the URL contains #gohere I want to automatically show this div and hide it only if .show_hide is clicked.

  • 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-05T10:23:11+00:00Added an answer on June 5, 2026 at 10:23 am

    Set the divs ID to be gohere, then you can do:

    $('.show_hide').click(function(){
        $($(this).attr('href')).slideToggle();
    });
    

    since your href attribute will contain #gohere, the selector for the slidetoggle will end up being #gohere, which corelates to your divs ID.

    EDIT:
    for the first part of your question, you can get the current hash tag from window.location.hash.

    if (window.location.hash.length > 0) {
        $(window.location.hash).show();
    }
    

    You should probably put some better error checking in there, but it should work.

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

Sidebar

Related Questions

I have this simple function: <script type=text/javascript> //<![CDATA[ jQuery(function($){ function here(b){alert(b);} ; here(6); });
I have a simple peice of jQuery code that submits a form and hides/shows
I have a simple jquery script that copies a text from a html element
I have a simple jQuery script that slides a contact form up from the
I have a simple file that has a Jquery script it in that looks
I have two simple scripts, the first shows a div when clicked. Inside that
I have a simple show/hide jquery script that works fine on its own, The
I have a div and a simple jQuery code that calls the div on
I have an inline script on my page as such: <script type=text/javascript> var rootPath
I have a very simple jQuery script.. all I want it to do is

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.