What could be causing the fourth tab to not show any data while the first three tabs are functioning as expected?

I've encountered an issue with my HTML tabs. While I can easily switch between the first three tabs and view their content, tab 4 doesn't seem to display its associated data. It's puzzling why tab 4 is not working when the others are functioning correctly.

Check out the tabs here

<div class="tabs">
  <ul class="tabs-list">
     <li class="active"><a href="#tab1">Tab 1</a></li>
     <li><a href="#tab2">Tab 2</a></li>
     <li><a href="#tab3">Tab 3<a/></li>
      <li><a href="#tab4">Tab 4<a/></li>
  </ul>
  <div id="tab1" class="tab active">
      <div id="">
        <strong>TAB 1:</strong>
        Lorem ipsum dolor sit amet, consectetur adipisicing elit. Rerum quod doloribus quaerat ab porro at necessitatibus alias molestiae dolores facere rem debitis dolorum inventore, vel error animi deleniti ipsum, labore.
      </div>
  </div>
  <div id="tab2" class="tab">
    <div id="">
        <strong>TAB 2:</strong>
        Lorem ipsum dolor sit amet, consectetur adipisicing elit. Rerum quod doloribus quaerat ab porro at necessitatibus alias molestiae dolores facere rem debitis dolorum inventore, vel error animi deleniti ipsum, labore.
      </div>
  </div>
  <div id="tab3" class="tab">
    <div id="">
        <strong>TAB 3:</strong>
        Lorem ipsum dolor sit amet, consectetur adipisicing elit. Rerum quod doloribus quaerat ab porro at necessitatibus alias molestiae dolores facere rem debitis dolorum inventore, vel error animi deleniti ipsum, labore.
      </div>
  </div>
  <div id="tab4" class="tab">
   <div id="">
        <strong>TAB 4:</strong>
        Lorem ipsum dolor sit amet, consectetur adipisicing elit. Rerum quod doloribus quaerat ab porro at necessitatibus alias molestiae dolores facere rem debitis dolorum inventore, vel error animi deleniti ipsum, labore.
      </div>
  </div>
</div>


$(document).ready(function(){
  $(".tabs-list li a").click(function(e){
      e.preventDefault();
  });
  $(".tabs-list li").click(function(){
      var tabid = $(this).find("a").attr("href");
      $(".tabs-list li,.tabs div.tab").removeClass("active");
      $(".tab").hide();
      $(tabid).show();
      $(this).addClass("active");
  });
});

Answer №1

It looks like your opening and closing "a" tags are not valid.

  <ul class="tabs-list">
     <li class="active"><a href="#tab1">Tab 1</a></li>
     <li><a href="#tab2">Tab 2</a></li>
     <li><a href="#tab3">Tab 3<a/></li> <-- needs to be </a>
      <li><a href="#tab4">Tab 4<a/></li> <-- ditto!
  </ul>

For correct formatting, it should look like this:

  <ul class="tabs-list">
     <li class="active"><a href="#tab1">Tab 1</a></li>
     <li><a href="#tab2">Tab 2</a></li>
     <li><a href="#tab3">Tab 3</a></li> 
      <li><a href="#tab4">Tab 4</a></li> 
  </ul>

Answer №2

The closing anchor tags for tab 3 and tab 4 need to be corrected. Please update them with the following lines.

 <li><a href="#tab3">Tab 3</a></li>
 <li><a href="#tab4">Tab 4</a></li>

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

"Anticipate the presence of expression" mistake

On my page, users can choose a registration type and input content into the tinymce textarea to associate that content with the selected registration type. However, an error "expression expected" is appearing in the code below? The console indicates that ...

What could be causing the validation messages to not display when utilizing Ajax in an ASP.NET Core application?

I have encountered an issue while using Ajax with my ASP.NET Core application. When I submit the form, the validation messages for invalid inputs do not appear as expected. Interestingly, when I disable AJAX, the validation messages start showing up. How ...

How can you proactively rebuild or update a particular page before the scheduled ISR time interval in Next.js?

When using NextJS in production mode with Incremental Static Regeneration, I have set an auto revalidate interval of 604800 seconds (7 days). However, there may be a need to update a specific page before that time limit has passed. Is there a way to rebui ...

Joi has decided against incorporating custom operators into their extended features

I am having trouble extending the joi class with custom operators. My goal is to validate MongoDB Ids, but when I try to use the extended object, I encounter the following error: error: uncaughtException: JoiObj.string(...).objectId is not a function TypeE ...

What is the method for adding or removing options from a collection_select (Drop-Down List) in Rails?

I am seeking guidance on how to dynamically add and remove values from my dropdown lists. Below is the code snippet I have in my View/Project/_form.html.erb: <div class="control-group"> <%= vf.label(:category_id, :class => "control-label") % ...

What is the reason for Jest attempting to resolve all components in my index.ts file?

Having a bit of trouble while using Jest (with Enzyme) to test my Typescript-React project due to an issue with an alias module. The module is being found correctly, but I believe the problem may lie in the structure of one of my files. In my jest.config ...

Tips on how to ensure that an onClick JS function only runs when radio buttons are selected

I have implemented the formslider library for a form on my website. In the demo, the slide transitions to the next set of questions based on a click event triggered by radio buttons (answers). However, when I attempted to include checkboxes for users to s ...

Guide to setting up an object array in JavaScript with unique child elements and no duplicate values

I have an array that looks like this: sampleArray = ["x", "y", "z". "a.b", "a.b.c", "a.b.d", "a.e.f", "a.e.g"] However, I am aiming to transform it into the following structure, or something similar to it: newArray: [ { "x": [] }, ...

After executing the controller function in AngularJS, the loading icon transitions into a status icon

Is it possible to dynamically change an icon in my view based on the status of a controller function? I want the icon to initially display as a spinning wheel to indicate loading and activity while the function is executing. https://i.stack.imgur.com/I ...

Utilizing imported components to set state in React

In my project, I created a functional component named Age and imported it into another functional component called Signup. This was done in order to dynamically display different divs on a single page based on the authentication status of the user. By sett ...

Having difficulty accessing the ::after element on Firefox when attempting to click

I've encountered an issue with my HTML and CSS code - it functions perfectly on Chrome, yet behaves differently on Firefox. button#groupToggle { background: 0 0; border: 1px solid #e6e6ed; color: #222; float: none; margin: 0 0 ...

Could someone assist me in figuring out the reason behind my fetch method sending undefined values?

Looking for some assistance with my fetch implementation issue. I am currently working on integrating stripe into my online grocery store website utilizing a node.js server with express, and ejs for frontend integration. The client-side JavaScript uses a f ...

Converting Epoch timestamp to AM/PM format in a React render function

I am currently working on a personal project using React.js. I have successfully fetched an API, and one of the values returned is an Epoch timestamp. My goal is to display this timestamp in a human-readable format such as am/pm. The Epoch timestamp is dis ...

Subpar resolution of PNG images displayed in HTML canvas

My attempt to draw a PNG image onto the canvas is resulting in poor quality. I am using the drawImage method as shown below: src = folder+self.cur+".png"; imageObj.src = src; imageObj.onload = function() { context.clearRect(0, 0, cv, ch), context.drawImag ...

Getting the local folder name using AngularJs

Is there a way to retrieve the directory name by browsing to a folder and clicking a button? I was considering utilizing <input type="file" /> to achieve this. ...

Is it possible to establish a CSS minimum width that is relative to a different element?

Is it possible to set the min-width of a submenu in CSS to be equal to that of the corresponding link in a navigation menu? I am using LESS for my styling. <ul> <li> <a href="">Item FooBarBaz</a> <ul class="submenu"&g ...

Retrieving the value of a specific property nested within a JSON object using basic JavaScript

Hey there! Thanks for taking the time to check out my question. I'm diving into JavaScript and I've hit a roadblock trying to solve this particular problem: I'm looking to extract the value of a property nested within a JSON object under a ...

What is the best way to merge multiple statements into one before passing them into a JavaScript method?

I am faced with several javascript statements like the ones listed below: $('#' + xxx_slot_name1).children().remove(); $('#' + xxx_ad_slot_name2).children().remove(); $('#' + xxx_ad_slot_name3).children().remove(); $('#& ...

After removing an element from an array in Vue.js, how can we adjust its class to reflect the change?

Apologies for my lack of proficiency in English. I am eager to find a solution to resolve these issues. I am working on a todolist and encountering an issue where the class ('centerLine') continues to affect the next element after deleting an a ...

"AngularJS makes it easy for the logged-in user's information to be accessible and available across

I need to ensure that user information is accessible across all views after logging in. How can I adjust the code to be able to retrieve the pseudonym from another view? Could you provide an example as well? Below is my login controller: app.controller ...