0

I am using bootstrap carousel and trying to set an item on another page active.

Here are the snippets.

The navbar is on the main page,

<ul class="navbar">
     <a href="#" class="nav-item active" data-target="#myContent" data-slide-to="??"  >nav 1 </a></li>
     <a href="#" class="nav-item" data-target="#myContent" data-slide-to="??" >nav 2</a> </li>          

and myCarousel is on the another page, 

<div id="myContent" class="carousel slide" >
  <div class="carousel-inner">     
    <div class="item active "> Item 1 </div>
    <div class="item> Item 2 </div>
  </div>
</div>

How can I set the second item, Item 2, active when the nav-2 is clicked?

Thanks in advance.

Th4t Guy
  • 1,442
  • 3
  • 16
  • 28
user2307087
  • 423
  • 11
  • 25

1 Answers1

1

According to docs just add onclick event listener to nav-2 element:

$('.carousel').carousel(1);
exec
  • 52
  • 3
  • Thanks. It will be working ff those are on the same page(?). I am new to javascript. How I can call the carousel on the other page? – user2307087 Aug 17 '14 at 04:21
  • If second page (window?) is a child of first page then see [this](http://stackoverflow.com/questions/1258563/how-can-i-access-the-dom-tree-of-child-window) article. Or please explain what is "other page". – exec Aug 18 '14 at 07:16