By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,471 Members | 722 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,471 IT Pros & Developers. It's quick & easy.

Trouble with javascript and bootstrap

P: 3
Hey guys, I'm having trouble using the jQuery .click function on a navigation bar made using bootstrap. Here is the code

Expand|Select|Wrap|Line Numbers
  1. <div class="navbar navbar-inverse navbar-fixed-top navbar-wrapper" role="navigation" id="bar-1">
  2.  <div class="container">
  3.   <div class="navbar-header">
  4.     <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".collapse">
  5.       <span class="sr-only">Toggle navigation</span>
  6.       <span class="icon-bar"></span>
  7.       <span class="icon-bar"></span>
  8.       <span class="icon-bar"></span>
  9.     </button>
  10.     <a class="navbar-brand" href="index.html">Project</a>
  11.   </div>
  12.   <div class="collapse navbar-collapse">
  13.     <ul class="nav navbar-nav navbar-left">
  14.       <li class="active"><a href="index.html">Home</a></li>
  15.       <li><a href="#about">Current Courses</a></li>
  16.       <li class="dropdown">
  17.       <a href="#" class="dropdown-toggle" data-toggle="dropdown">Projects<b class="caret"></b></a>
  18.       <ul class="dropdown-menu">
  19.        <li><a href="#" id="sudoku1">Sudoku</a></li>
  20.        <li><a href="#" id="huffman">Huffman</a></li>
  21.        <li><a href="#" id="spantree">Spantree</a></li>
  22.        <li><a href="#" id="calendar">Calendar</a></li>
  23.        <li><a href="#" id="snake">Snake</a></li>
  24.        </ul>
  25.       </li>
  26.       <li><a href="#Resume">Resume</a></li>
  27.         <li><a href="#contact" data-toggle="modal">Contact</a></li>
  28.       </ul>
  29.   </div><!--/.nav-collapse -->
  30.  </div>
  31. </div>
  32.  
and here is a simple onclick jquery
Expand|Select|Wrap|Line Numbers
  1. $('#snake').click(function(){alert("Works!");});
  2.  
Apr 20 '14 #1
Share this Question
Share on Google+
2 Replies


Dormilich
Expert Mod 5K+
P: 8,639
and what trouble do you have?
Apr 20 '14 #2

P: 1
Not sure what your problem is, it works as expected: http://jsfiddle.net/V9CfA/1/
May 14 '14 #3

Post your reply

Sign in to post your reply or Sign up for a free account.