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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:27:03+00:00 2026-06-09T07:27:03+00:00

I am using Twitter Bootstrap’s button groups to toggle between different content. An example

  • 0

I am using Twitter Bootstrap’s button groups to toggle between different content. An example can be seen at http://jsfiddle.net/g8KSf/

Basically, if you click “Games”, the games_container div will appear and the other divs will be hidden. I’ve got that working fine.

I store the post type in the database as post, game, video, etc and I want to be able to open the related div on page load instead of just on click. Right now the post_container is shown by default when the page is loaded.

Say I have a PHP variable $post_type = 'game';, how can I make the game_container show on page load while still having it toggle by clicking?

This is the js I have so far:

$('.container').hide();
$('#post_container').show();

$('.post_types button').click(function(){
        var target = "#" + $(this).data("target");
        $(".container").not(target).hide();
        $(target).show();
        $('#post_type').val($(this).text());
});​
  • 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-06-09T07:27:05+00:00Added an answer on June 9, 2026 at 7:27 am

    To show game container on load, you need to replace this line

    $('#post_container').show();
    

    to

    $('#game_container').show();
    

    Refer LIVE DEMO

    And also currently you are using

    $('#post_type').val($(this).text());
    

    Here rather than using this for this line $(this).text(), use target variable as below

    $('#post_type').val($(target).text());
    

    UPDATE:

    To show dynamically on page load,

    1. Store the value of post_type in variable

      var ptype = ...STORE THE POST TYPE VALUE...;

    2. Pass the value to this line

      $('#'+ptype+'_container').show();
      OR
      $('#'+$post_type+'_container').show();

    Refer LIVE DEMO 2

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

Sidebar

Related Questions

Using Twitter Bootstrap's bootstrap-tab.js, I have: <ul class=tabnavcenter id=myTab> <li class=active><a href=#home data-toggle=tab>about</a></li> <li><a
I just started using Twitter Bootstrap http://twitter.github.com/bootstrap/scaffolding.html and I'm looking for the grey/blue navbar
I am trying to find only new tweets using Twitter Search. For example: http://search.twitter.com/search?tag=bruins&lang=en&rpp=100&result_type=recent&since=22451745267388417
For example, www.breakingnews.com is using Twitter Bootstrap, which does a great job at this
I am using Twitter Bootstrap, but can't understand How to set margin 0 0
I am using Twitter Bootstrap's Javascript radio toggle buttons and want to get form
I recently started using Twitter Bootstrap and I can't seem to grasp what spans
I'm using twitter bootstrap. I'm trying to create a button with dropdown that should
Using Twitter Bootstrap's [Tabbable Tabs][1], it says to: Enable tabbable tabs via javascript (each
I am using twitter bootstrap and I would like a container div to stretch

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.