Default display as collapsible. Prefer them to be concealed initially

Looking for help with creating collapsible buttons. Currently, they show and collapse onclick, but I want them to be hidden by default. This is part of a personal website project where I am teaching myself HTML. What do I need to change? I tried using buttons but prefer the styling of links with href.

HTML

<div class="container-fluid">
            <div class="jumbotron">
                <div class="row">
                    <h2 class="work_text_mobile" style="margin: auto"><a href="#" class="page-link project" onclick='changeProject("MyUPMC")'>MyUPMC GoLive</a></h2>
                    <h2 class="work_text_mobile" style="margin: auto"><a href="#" class="page-link project" onclick='changeProject("SSO")'>AWS SSO</a></h2>
                    <h2 class="work_text_mobile" style="margin: auto"><a href="#" class="page-link project" onclick='changeProject("S3")'>S3 Static Content</a></h2>
                    <h2 class="work_text_mobile" style="margin: auto"><a href="#" class="page-link project" onclick='changeProject("SSM")'>SSM Replicator</a></h2>
                    <h2 class="work_text_mobile" style="margin: auto"><a href="#" class="page-link project" onclick='changeProject("SeniorDesign")'>Senior Design</a></h2>
                </div>
            </div>
      </div>
      <div class="container-fluid">
            <div class="jumbotron tab" id="MyUPMC" style="background-color: rgb(252,181,20)">
               <h2 style="text-align:center">Blah1</h2>
               <p>Blah...</p>
               <img src="images/myupmc_logo1.png" style="display: block;width: 90%;height: 90%;margin: auto; overflow: hidden">
            </div><div class="jumbotron tab" id="SSO" style="background-color: rgb(252,181,20)">
               <h2 style="text-align:center">Blah2</h2>
               <p>Blah...</p>
               <img src="images/psb.png" style="display: block;width: 90%;height: 90%;margin: auto; overflow: hidden">
            </div><div class="jumbotron tab" id="S3" style="background-color: rgb(252,181,20)">
               <h2 style="text-align:center">Blah3</h2>
               <p>Blah...</p>
               <img src="images/bits_header.jpg" style="display: block;width: 90%;height: 90%;margin: auto; overflow: hidden">
            </div><div class="jumbotron tab" id="SSM" style="background-color: rgb(252,181,20)">
               <h2 style="text-align:center">Blah4</h2>
               <p>Blah...</p>
               <img src="images/full_adder.jpg" style="display: block;width: 90%;height: 90%;margin: auto; overflow: hidden">
            </div>
            <div class="jumbotron tab" id="SeniorDesign" style="background-color: rgb(252,181,20)">
               <h2 style="text-align:center">Senior Design - blah, blah, blah</h2>
               <p>Blah...</p>
               <img src="images/senior_design.jpg" style="display: block;width: 90%;height: 90%;margin: auto; overflow: hidden">
            </div>
      </div>

CSS

.project:link, .project:visited {
  background-color: rgb(252,181,20);
  color: black;
  border: 2px solid black;
  padding: 10px 20px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
}
.project:hover, .project:active {
  background-color: black;
  color: white;
}
div.jumbotron{
    background-color: #D3D3D3;
    margin-top: 16px;
}

JS

function changeProject(requestedProject){
    var requested_tab = document.getElementById(requestedProject);

    if(requested_tab.style.display == 'block'){
        requested_tab.style.display = "none";
        return;
    }
    var all_tabs = document.getElementsByClassName("tab");
    for(var i = 0; i < all_tabs.length; i++){
        all_tabs[i].style.display = 'none';
    }
    requested_tab.style.display = 'block';
}

Answer №1

To conceal your tabs initially when the page loads, simply include this snippet at the end of your css file:

div.jumbotron.tab{
  display:none;
}

This code targets any div with both the "jumbotron" and "tab" classes, effectively hiding your tabs. Wishing you success as you progress in your learning journey!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What could be causing the issue with Vue's v-model not functioning properly with an array prop?

I created a unique custom component that uses the modelValue prop and emits the update:modelValue event. When I pass an array in the parent component, the list does not update when pressing the button: CustomComponent.vue <template> <div> ...

Managing iframes in React using reference methods

Trying to set the content of an iframe within a React component can be a bit tricky. There is a component that contains a handleStatementPrint function which needs to be called when the iframe finishes loading. The goal is to print the loaded iframe conten ...

Choose everything except for the list and its heading

I have a portion of HTML code on my hands. <div class="ProductDescriptionContainer"> <p>This handsome Clergy Shirt has a trim low neckband with two reinforced buttonholes, one at the front, one at the back, to align with Ziegler's Collare ...

I keep receiving a blank request body while using express.js

I'm having trouble retrieving data from my database as the body of the request is empty. I've tried using parse-body and CORS, but it's still not working. I attempted various solutions without success. Backend code: const bodyParser = requir ...

Turn off selective bloom in ThreeJS for the background of the scene

I am using ThreeJS to create a selective bloom effect to showcase glowing parts on an object using an emissive map as a filter. I recently enabled my environment map and noticed that the bloom is affecting the appearance of the scene.background. This is t ...

Transferring an object between components using varying routes

Recently diving into the world of Angular 6, I have been working on developing an application with this powerful framework. However, one challenge that came my way was figuring out how to effectively share data between components. In my project, I have tw ...

Stop the context menu from popping up when the element is right-clicked

Is there a way to create a custom right-click interaction for an element on my website, <div class="myElement"></div>? I want to avoid the default context menu from popping up when the user right-clicks on this element in order to enhance the u ...

Modify the appearance of the gradient progression bar

I am working on a gradient progress bar with the following code: CSS: .progressbar { height: 15px; border-radius: 1em; margin:5px; background: linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%,transparent 25%, t ...

What is the best way to manage the 'content' attribute in TSX?

I'm currently developing an application that utilizes schema.org. In the code snippet below, you can see how I've implemented it: <span itemProp="priceCurrency" content="EUR">€</span> According to schema.org do ...

What is the best way to replicate a CSS zoom effect in Firefox?

After implementing this code for a menu on my website, I noticed that it is not compatible with Firefox when testing it across different browsers. li { display: inline-block; list-style: none inside none; text-align: center; } li a:before { ...

What is the best way to select the second HTML element identical to the first element using Selenium and Python?

Is there a way to click on a specific instance of a button that appears multiple times on a website? For example, how can I click on the second button and not the first one? Below is the code for the button I am trying to target: <a href="/us/en/outlet ...

Unfortunately, we encountered an AJAX error while trying to access data from the website datatables.net. You can find

I'm currently working on adding data to a datatables.net datatable using a JSON response, following the example provided here. To achieve this, I am making use of an AJAX call to fetch a JSON response from a database. After obtaining the data, I uti ...

The behavior of the div element is not as expected when using "<select>", but it functions properly when using "<input>"

I found this code snippet on http://jsfiddle.net/Lijo/PJcZQ/. It features two divs labeled "GROUP1" and "GROUP2" with slightly different content. GROUP 1 <div class="secondTextBox"> <select name="ctl00$detailContentPlaceholder$ddlStatus" id= ...

Triggering the Vuetify select/autocomplete/combobox menu to open upon focusing on it

I'm working on implementing a Vuetifyjs Autocomplete feature. My goal is to have the menu open when the user focuses on it using the tab key after entering information in a previous input field. Below is a snippet of the code I am using: <div id=" ...

Using jQuery Datepicker, showcase two distinct datepickers on a single page

Currently, I am utilizing the jQuery [Datepicker][1] on a website, but I am facing challenges when attempting to display two datepickers on the same page in different manners. The first one should only appear once you click the text box, and once a date i ...

Unable to synchronize Rijdnael encryption across C# and Javascript/Node platforms

I have encountered an issue while trying to convert a Rijndael encryption function from C# to Node. Despite using the same Key, IV, Mode, and Block Size, I am unable to achieve matching results. What could be causing this discrepancy? C# MRE: using System ...

Utilize jQuery to set a cookie, then apply the bodyclass retrieved from the cookie upon page

I have a button that changes the body class to .blackout For this, I am utilizing js-cookie library to manage cookies. The code snippet associated with my button is shown below: <script> $('#boToggle').on('click', function(e) { ...

Highlight the title with a stylish CSS animation effect

I have a challenge with animating div tags once they come into view on the page. Thanks to waypoint.js, I have successfully achieved the 'in viewport' trigger, but now I need help with the animation part. Specifically, I am looking to add a grey ...

Nodemailer contact form malfunctioning

I've been working on setting up a contact form in React and utilizing nodemailer to send messages to my email, but I seem to be encountering some issues. I have a server.js file located in the main folder along with Mailer.js which contains the form c ...

Conditional statement in Javascript for document.cookie

I am attempting to create a basic if statement that relies on the value of a cookie. The function looks like this: function setHomePage() { if ($.cookie('settingOne') == 'jjj') { $('.secO').css('display', & ...