what's causing the tabs in bootstrap to malfunction

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<ul class="nav nav-tabs">
  <li class="active"><a data-toggle="pill" href="#home">Images</a>
  </li>
  <li><a data-toggle="pill" href="#songs">Songs</a>
  </li>
  <li><a data-toggle="pill" href="#menu2">Video</a>
  </li>
</ul>

<div class="tab-content">
  <div id="home" class="tab-pane fade in active">
    <div class="uploaded-image-ct">
      <button type="button" class="btn btn-default btn-sm">
        <span class="glyphicon glyphicon-picture"></span> Upload image
      </button>

    </div>
  </div>

  <div id="songs" class="tab-pane fade">
    <div class="form-group">
      <input id="song-link" placeholder="Paste Soundcloud link here" type="text">
    </div>
  </div>

  <div id="video" class="tab-pane fade">
    <div class="form-group">
      <input placeholder="Paste YouTube link here" type="text">
    </div>

  </div>

</div>

the video section should show youtube which there on html but not on the page.

i checked whether jquery is loaded ahead of bootstrap.js.. But still it is not working. Turns out the tab button is not working like it should. although when u click on image button image section will be shown. Is it the problem only with input tag?

Answer №1

Snippet in Action:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<ul class="nav nav-tabs">
  <li class="active"><a data-toggle="pill" href="#home">Images</a>
  </li>
  <li><a data-toggle="pill" href="#songs">Songs</a>
  </li>
  <li><a data-toggle="pill" href="#video">Video</a>
  </li>
</ul>

<div class="tab-content">
  <div id="home" class="tab-pane fade in active">
    <div class="uploaded-image-ct">
      <button type="button" class="btn btn-default btn-sm">
        <span class="glyphicon glyphicon-picture"></span> Upload image
      </button>

    </div>
  </div>

  <div id="songs" class="tab-pane fade">
    <div class="form-group">
      <input id="song-link" placeholder="Paste Soundcloud link here" type="text">
    </div>
  </div>

  <div id="video" class="tab-pane fade">
    <div class="form-group">
      <input placeholder="Paste YouTube link here" type="text">
    </div>

  </div>

</div>

The anchor tag in jQuery should have the correct href, pointing to the specific tab-pane.

Your original code was:

<ul class="nav nav-tabs">
  <li class="active"><a data-toggle="pill" href="#home">Images</a>
  </li>
  <li><a data-toggle="pill" href="#songs">Songs</a>
  </li>
  <li><a data-toggle="pill" href="#menu2">Video</a>
  </li>
</ul>

To fix this, ensure that the href for the Video tab points to #video:

<ul class="nav nav-tabs">
  <li class="active"><a data-toggle="pill" href="#home">Images</a>
  </li>
  <li><a data-toggle="pill" href="#songs">Songs</a>
  </li>
  <li><a data-toggle="pill" href="#video">Video</a>
  </li>
</ul>

Answer №2

Your video pill has the following:

  <li><a data-toggle="pill" href="#menu2">Video</a>

however, the id of the tab you are trying to link it to is:

<div id="video" class="tab-pane fade">

To resolve this issue, you need to change the pill to match the same id

 <li><a data-toggle="pill" href="#video">Video</a>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<ul class="nav nav-tabs">
  <li class="active"><a data-toggle="pill" href="#home">Images</a>
  </li>
  <li><a data-toggle="pill" href="#songs">Songs</a>
  </li>
  <li><a data-toggle="pill" href="#video">Video</a>
  </li>
</ul>

<div class="tab-content">
  <div id="home" class="tab-pane fade in active">
    <div class="uploaded-image-ct">
      <button type="button" class="btn btn-default btn-sm">
        <span class="glyphicon glyphicon-picture"></span> Upload image
      </button>

    </div>
  </div>

  <div id="songs" class="tab-pane fade">
    <div class="form-group">
      <input id="song-link" placeholder="Paste Soundcloud link here" type="text">
    </div>
  </div>

  <div id="video" class="tab-pane fade">
    <div class="form-group">
      <input placeholder="Paste YouTube link here" type="text">
    </div>

  </div>

</div>

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

In search of a comprehensive demonstration of how to use JQuery/Ajax for pinging with success and failure detection

Given that the process is asynchronous with multiple requests happening in parallel, I would like a solution that can handle these requests and identify which success/failure corresponds to each specific request. I am considering utilizing the jqXHR Object ...

Google Chrome's development tools are unable to detect the manifest

I have a file named manifest.json, and I included it in my HTML using <link rel="manifest" href="./manifest.json">. Despite everything seeming correct, Chrome developer tools are unable to detect my manifest file! This is the content of my manifest ...

The error "clearRect is not defined in javascript" occurs when the property is being called on an undefined object in the JavaScript

I've encountered a similar question before, but unfortunately, the solution provided didn't help me! I'm relatively new to JavaScript and have been struggling with this issue for nearly a day now without success. The structure of my class a ...

Styling group headers within an unordered list using pure CSS - possible?

Hey there, I'm looking to spruce up my UL by adding group headers. Here's a sneak peek at the structure I have in mind (keep in mind this is generated dynamically from a database): <ul> <li class='group group-1'> < ...

What could be causing such a significant impact on the row height in a CSS table when a tiny image is inserted next to an input box?

Currently, I am facing a unique challenge while setting up a form using CSS tables. The issue is best explained through a fiddle: http://jsfiddle.net/GdgV4/6/ In the third row, you'll notice that adding an image with a height less than the input box ...

Accessing a JSON file from a nearby location using JavaScript

I am currently working on an artistic project based on weather data, which will be hosted locally with the JSON file updating via FTP synchronization. This means that the JSON file will be sourced from the same computer where it is stored. The code snippet ...

Enhance Material UI with custom properties

Is it possible to add custom props to a Material UI component? I am looking to include additional props beyond what is provided by the API for a specific component. For example, when using Link: https://material-ui.com/api/link/ According to the document ...

Is Dealing with Multiple AJAX Requests a Pain?

Currently, I am utilizing AJAX to retrieve a list of active streams from TwitchTV along with their viewers, updating every second. Sometimes the stream list can become quite long, so my plan is to divide the AJAX requests into 2 or 3 parts: 1) Obtain Numb ...

Cursor vanishes until mouse movement detected (Chrome browser)

In the HTML page I created, the mouse cursor is initially set to none. However, there are certain circumstances where I need it to switch to crosshair. The issue I am facing is that the cursor does not appear unless the user moves the mouse. If the mouse r ...

Navigating the absence of Prismic's ability to use the <blockquote> element in their rich text editor

My experience with Prismic as a headless CMS has been mostly positive, but I recently encountered an issue that surprised me - the lack of support for a simple blockquote. It's baffling to me that such a basic HTML element is not natively supported by ...

Utilize OpenLayer3 to showcase Markers and Popups on your map

I am currently exploring how to show markers/popups on an osm map using openlayers3. While I have come across some examples on the ol3 webpage, I'm interested in finding more examples for coding markers/popups with javascript or jquery, similar to som ...

Issue encountered while importing TypeScript files from an external module in a Next.js project

Encountering an issue within my Next.js project with the following project structure: ├── modules/ │ └── auth/ │ ├── index.ts │ ├── page.tsx │ └── package.json └── nextjs-project/ ├─ ...

Why does text display differently in HTML (Firefox) on Ubuntu compared to Windows 7?

When viewing the HTML and CSS code in Firefox on Windows, everything appears fine. However, when I view it in Firefox on Ubuntu, it looks out of place. How can this be corrected? Any suggestions? Additional information: The CSS code used for the text show ...

Can anyone provide guidance on how to create this particular shadow effect using CSS?

Is there a method to use CSS to create a green shadow in that particular shape? ...

Unable to get jQuery waypoints to function on local server

Currently, I am working with jQuery. I downloaded an example shortcut for infinite scroll from jQuery Waypoints and tried to use it. However, when the page reaches the end, the web console displays the following error: XMLHttpRequest cannot load file:// ...

Content that is set to a fixed position within a hidden element will remain at the top

translate3d(0%, 0px, 0px); is causing issues with my position fixed element. In my demo, you'll notice that clicking the button should open up the content just fine, but it is supposed to stay fixed at the top in a position fixed. Therefore, when scr ...

progressing both forward and backward through every month

I am currently working on a project that involves creating a calendar using JavaScript. I have implemented functionalities where I can navigate back and forth through months, fetching the days within each month. However, I am facing an issue where if I go ...

Listening for Events from Child Components in Vue.js

I am struggling to figure out how to send an event from a child component to its parent in order to change the view. Although I have been able to create and emit the event, my template does not seem to be properly registering it. I am working with Single ...

Verify Session Cookies through JSONP requests

I've developed a bookmark that pulls all images from a webpage upon clicking and sends the image's src back to another server using JSONP. Challenge: The remote server must validate session authentication cookies to confirm that the user sending ...

Potential bug may arise with the hashchange event

Recently, I stumbled upon a rather unique bug in my Javascript code that has left me puzzled. Here's the scenario: within a parent div with relative positioning, there are three child divs positioned absolutely side by side. Each child div is 1200px ...