Jump to content

Recommended Posts

Hey there. I just recently started to use Bootstrap and was wondering why this dropdown is not working, I have exactly what they have on their example site.

<!DOCTYPE html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script href="js/jquery.js" type="text/javascript" ></script><script href="js/jquery-ui.js" type="text/javascript" ></script>  <script href="js/bootstrapjs" type="text/javascript" ></script><script href="js/bootstrap-dropdown.js" type="text/javascript" ></script><link href="css/bootstrap.css" rel="stylesheet" type="text/css" /><link href="css/bootstrap-responsive.css" rel="stylesheet" type="text/css" /><!-- <script href="js/document.js" type="text/javascript" ></script> --><script type="text/javascript"> $('.dropdown-toggle').dropdown();  </script></head> <body><div class="navbar navbar-fixed-top">  <div class="navbar-inner">	<div class="container"><ul class="nav pull-left">		<a class="brand" href="#">Project name</a></ul><div class="nav-collapse"><ul class="nav pull-right">			<li><a href="#">Blog</a></li>			<li class="divider-vertical"></li><li><a href="#">Facebook</a></li>			<li class="divider-vertical"></li><li><a href="#">Twitter</a></li>			<li class="divider-vertical"></li><li><a href="#">Flickr</a></li>			<li class="divider-vertical"></li><li><a href="#">YouTube</a></li><li class="divider-vertical"></li> <li class="dropdown">          <a href="#" class="dropdown-toggle">Dropdown   <b class="caret"></b></a>          <ul class="dropdown-menu">            <li><a href="#">Secondary link</a></li>            <li><a href="#">Something else here</a></li>            <li class="divider"></li>            <li><a href="#">Another link</a></li>          </ul>           </li>		  </ul>		</div><!-- /.nav-collapse -->	</div>  </div></div> </body> </html>

Edited by peterxeno
Link to post
Share on other sites

This code:

<script type="text/javascript"> $('.dropdown-toggle').dropdown();  </script>

will get ran before the <body> of the document is loaded, because it's in the <head>. You can tell it to run the code when the window is loaded, by assigning a function to window.onload:

<script type="text/javascript"> window.onload = function() {$('.dropdown-toggle').dropdown();} </script>

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...