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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:20:59+00:00 2026-05-31T16:20:59+00:00

Just a quick one, hopefully. I’ve coded up this: <script> $(div.design-project).css(‘display’, ‘none’); function InsertContent(tid)

  • 0

Just a quick one, hopefully. I’ve coded up this:

<script>
$("div.design-project").css('display', 'none');
function InsertContent(tid) {
if(document.getElementById(tid).style.display == "none") {
    document.getElementById(tid).style.display = "block";
    }
else {
    document.getElementById(tid).style.display = "none";
    }
}
</script>

Which, if a link has the href:

href="javascript:InsertContent('design-project-1');"

it displays that div below. And if you click it again it disappears. Then if you click another link that say has the href:

href="javascript:InsertContent('design-project-2');"

it’ll display that div and so forth.

However, if you have one div open, and click on another anchor link to open another div, it doesn’t close the one already open.

Any ideas? Also, if there’s a better way to do this then please let me know.

Thanks,
R

Here is the HTML as requested:

<a class="design-projects-slides-title" href="javascript:insertDesignProjectContent('design-project-1');">Title of project</a>

<!-- start of .design-project --><div class="design-project" id="design-project-1">
                <div class="grid_6"><div class="project-info-area">
                    <h2>Title of project</h2>
                        <p>A rural retreat in the city. Built almost entirely from reclaimed element this little new-build timber cabin provides guest accommodation.<p>
                        <p>By coincidence a former chapel partition was found that matched the dimensions required. Used in their original painted condition, these doors became the front elevation and concertina open to one side - perfect for warm summer days. Further reclaimed elements include a bespoke curtain made from found patchwork, Victorian conservatory grills fitted over modern french heaters and industrial lights, taps, wash basin and an exposed shower fitting. Salvaged hardwood strip flooring and our Heathrow Terminal 2 stone fold from the floor to the walls. A thorough use of salvage all round!</p>
                </div></div>
                <div class="grid_6 project-info-images"><img src="http://placehold.it/460x540"></div>
                <div class="grid_6 project-info-images"><img src="http://placehold.it/460x540"></div>
                <div class="grid_6 project-info-images"><img src="http://placehold.it/460x540"></div>
                <div class="grid_12 project-info-images"><img src="http://placehold.it/940x540"></div>
                <div class="grid_6 project-info-images"><img src="http://placehold.it/460x540"></div>
                <div class="grid_6 project-info-images"><img src="http://placehold.it/460x540"></div>
                </div><!-- end of .design-project -->

UPDATE

In the end, I used a combination of your answers – thanks!

<!-- Reveal/hide sections on design projects/joinery -->
<script>
/* This is for the 'choose a project' reveal/hide */
$("div.slider-content").css('display', 'block');
$(".design-projects-slides-title").click(function() {
    $(".slider-content").hide();
});
/* This is for reveal/hide on the product content */
$(".design-project").hide()
$('.design-projects-slides-title').click(function(){
    var id = $(this).attr('id')
    var content_id = id+"-content"
    $('#'+content_id).slideDown('slow')
});
$(".slider-trigger").click(function() {
    $(".design-project").hide();
});
</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-05-31T16:21:00+00:00Added an answer on May 31, 2026 at 4:21 pm

    Use jQuery toggle to achieve what you are trying to do. e.g.

    function InsertContent(tid) {
        $('#'+tid).toggle()
    }
    

    Another improvement you should do is that instead of hardcoding the id in each href, just add a class to element, override onclick of element and toggle related content. To get related content you can use a nomenclature e.g. if you use id='myid' for anchor, use id="myid_content" for content, so in click function you can toggle content e.g.

    HTML:

    <a class="content-link" id="myid">click me</a>
    <div id="myid_content">
    Here is the content
    </div>
    

    JavaScript:

    $('.content-link').click(function(){
        var id = $(this).attr('id')
        var content_id = id+"_content"
        $('#'+content_id).toggle()
    }
    

    Here is a working sample on jsFiddle

    Better still is to keep clickable link and content inside a div, so that you don’t need to set id, just set some classes and with parent and child relations you can get what is content e.g.

    HTML

    <div class="content-wrap">
    <a class="content-link" >Click Me</a><br/>
    <div class="content">
    Here is the content for click me
    </div>
    </div>
    

    JavaScript:

    $('.content-link').click(function(){
        var id = $(this).parent().find(".content).toggle()
    })​
    

    See it in action here

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

Sidebar

Related Questions

Hopefully this is just a quick one and I'm missing something simple... I've got
Just a quick question (hopefully). I want to slide one div in front of
Just a quick one - I wrote a php script recently that dynamically creates
Just a quick one, if anyone knows: Is it possible to display a TomTom
Just a quick one, Is there anyway to shorthand this? It's basically determining the
Hopefully this is a quick one for someone in the knowledge but i am
Hopefully just a quick one. In XCode, trying to import a file called cocos2d.h
This is hopefully a quick/easy one. I know a way to work around this
This is just a quick one but I cant find what i need to
Quick question, hopefully I am just missing something simple. Ok I have one class

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.