Tips for limiting access to data from various tabs when the web page first loads

div#tabCtrl

div#page1 This table showcases the information for tab1

div#page2 This table showcases the information for tab2

Answer №1

If you want to hide the tabs initially and only show them when a user interacts with them, one way to achieve this is by setting the tabs to have a display of none by default. Then, upon the initial page load, you can set the default tab to display:block. I've put together a demonstration on jsFiddle to showcase this concept:

https://jsfiddle.net/9yPNKdu4/

<div id="tabCtrl"> <a href="#" onclick="activateTab('section1')">Section 1</a>
<a href="#" onclick="activateTab('section2')">Section 2</a>

<div id="section1" class="tab" style="display:none">Section 1 Content</div>
<div id="section2" class="tab" style="display:none">Section 2 Content</div>
</div>
<script>
    activateTab("section1");
</script>


//in a separate JavaScript file
var activateTab = function (tab) {
var tabs = document.getElementsByClassName("tab");

for (var i = 0; i < tabs.length; i++) {
    tabs[i].style.display = (tabs[i].id === tab ? "block" : "none");
    }
}

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

Is pre-filling still an option for setting up express accounts through Stripe? If so, what is the proper syntax for inputting information such as email, first name, and business

Here is an image of the initial landing screen where I would like the mobile phone pre-filled as well I have been following various online tutorials on setting up a Stripe Marketplace and have everything configured correctly. However, I am struggling with ...

Is there a way to prevent Express.js from triggering a file download in the browser?

I am attempting to preview a Word document file in the browser using an iframe: <iframe style="float:right;" src="/ViewerJS/#../demo/ohm2013.odp" width='400' height='300' allowfullscreen webkitallowfullscreen></iframe> (Fo ...

Unable to center div container with margin set to auto

I'm struggling to center my container on the website. My goal is to have it centered and take up about 80% of the page so I can incorporate an image slider and text inside. Using margin: 0 auto doesn't seem to be achieving what I want. The backgr ...

Issue with SVG mask not functioning when transform is applied

I am struggling to apply a mask to a transformed SVG element. When I try to do this with a path, the structure is the same. If I apply the mask to an element outside of the transformed group, it works as expected. However, if I try to do the same inside, t ...

I am facing some difficulties with my deployed CRA website on Github Pages, as it appears to be malfunctioning compared to when I was running it on localhost using VS Code

After deploying my CRA website on Github Pages, I noticed that it is not functioning the same as it did when running on localhost using VS Code. The site retrieves data from SWAPI and performs manipulations in various React components. While everything wor ...

I am interested in modifying the destination of the screen transition depending on the numerical input provided in the form

I have recently started working on a project using Spring Boot, Thymeleaf, and MySQL. For instance, when the input form is submitted with the value "1" as the DB ID, I expect to be redirected to http://localhost:8080/edit/1. However, I am facing an issue ...

using jQuery to disable textarea input

I have this HTML code and I am using jQuery: <div><textarea style="height: 150px; width: 250px" name="myName" id="myId" class="text ui-widget-content ui-corner-all" > </textarea></div> Currently, I validate this field after the su ...

Utilize Javascript ES6 to Sort Through Data in a Table

I require assistance with my project using Material UI and React. There are two key implementations that I need: I am looking to create a filtering system for all rows in each column as shown in the attached image. Additionally, I need a button that can a ...

Filtering a table using jQuery based on the class or data attributes

Issue arises when selecting the first "Icon" shows "Not found", then opting for "Talisman" does not display. It should show "Not Found". Is this achievable? Add the classes f-Icon, f-Ring, f-Neck. Then search for the value by class. Select either "Icon R ...

Changing base 64 into Mp3 audio format using PHP

I currently have an "audio" tag with a script (which is essentially a plugin) that receives and saves it as base64. This functionality is working properly. My goal now is to modify the script in order to send the base64 data to the server, convert it to m ...

Extract a free hour from the JavaScript time array without any filtering

In my Javascript array, I have the teaching schedule of a teacher for the day. { "time": [ { "start":"10:00","end":"11:00" }, { "start":"12:00","end":"01:00" }, { "start":"04:00","end":"06:00" } ] } My goal is to determine the free hours in the abo ...

Unable to forward page in EJS

Hey everyone, I've been struggling with trying to redirect to a page in EJS, but it just doesn't seem to work for some reason. Here's my code: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UT ...

Guidelines for populating data with an array

I have the following array: const dataArr = [[15, 14, 5], [16, 10, 2], [17, 6, 13], [18, 4, 8], [19, 7, 4]]; Now, I am populating another array using the above data as shown below: for (let i=0; i<dataArr.length; i++){ newData.push(dataArr[i]); ...

What causes CSS files to update automatically in an ExpressJS and NodeJS configuration?

I'm in the process of building a web application using NodeJS, ExpressJS, and Jade. In my project, I have a style.css file that is included like this. This is how my layout.jade looks: doctype html html head title= title link(rel='st ...

Can we safely save a value in session storage directly from the main.js file in Vue?

Throughout the user session managed by Vuex, I have a session storage value set to false that needs to be monitored. Setting up this value directly from the main.js file looks like this: import { createApp } from 'vue'; import App from './Ap ...

Using Mongoose to calculate and retrieve the total sum of elements within an array

In the following schema, I have defined the structure: let postScheme = new Schema({ title: { type: String, required: true }, body: String, isImage: Boolean, imageUrl: String, icon: String, time: { type: ...

The data type 'Event' cannot be assigned to the data type 'string' in this context

Recently diving into Angular, I came across a stumbling block while working through the hero tutorial. The error message that popped up was: Type 'Event' is not assignable to type 'string' You can see the error replicated here. ...

Divs that are 30% of their parent's width will not align vertically and will not fit in a parent div that is 100% width

I am attempting to vertically center the three child-divs <div class="section"> as 3 rows in one column within <div class="container_page_2">. When I refer to vertical alignment, I mean having an equal distance between the top of the page and ...

The error "map is not a function" occurs when trying to update the

I've encountered an issue with my links rendering on a page. I wrote a function that toggles a specific property from false to true based on whether the link is active or not, triggered by a click event. Upon inspecting the updated set of links, I no ...

Angular/JS encountered a premature end of program unexpectedly

I am taking my first steps in the world of web development with Angular (and JavaScript in general). I have been trying to rewrite some basic and common examples using Angular. One thing I attempted was to display a simple message using data binding. This ...