1

I'm writing a simple code using bootstrap for dropdown menu, the code seems fine. However, it doesn't expand when I clicked on the caret. I'm not sure what goes wrong. Can someone help me with this? Thanks for the help.

<!DOCTYPE html>
<html lang="en">
	<head>
		<title>thenewboston</title>
		<meta charset="utf-8">
		<meta name="viewpoint" content="width=device-width, initial-scale=1">
		<!-- Latest compiled and minified CSS -->
		<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
		
		<!-- Optional theme -->
		<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
		
		<!-- Latest compiled and minified JavaScript -->
		<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
	</head>
	
	<body>
		<nav class="navbar navbar-inverse">
			<div class="container-fluid">
				
				<!-- Logo -->
				<div class="navbar-header">
					<a href="navbar.html" class="navbar-brand">ABE TECHNOLOGY</a>
				</div>
				
				<!-- Menu Items -->
				<div>
					<ul class="nav navbar-nav">
						<li class="active"><a href="#">Home</a></li>
						<li><a href="#">About</a></li>
						<li><a href="#">Contact</a></li>
						
						<!-- drop down menu -->
						<li class="dropdown">
							<a href="#" class="dropdown-toggle" data-toggle="dropdown">My Profile <span class="caret"></span></a>
							<ul class="dropdown-menu">
								<li><a href="#">Friends</a></li>
								<li><a href="#">Photos</a></li>
								<li><a href="#">Settings</a></li>
							</ul>
						</li>
					</ul>
				</div>
			</div>
		</nav>
	</body>
</html>																						

3
  • Did you try to load the jquery plugin as I mention on my answer below? If Did that help? Commented Feb 22, 2016 at 10:20
  • I did added the jQuery in, but when I ran chrome or firefox it didn't work. However, when I ran the same code on jsfiddle.com, it works perfectly fine. Commented Feb 22, 2016 at 23:59
  • Oh, nvm. I used your jQuery and the minified javascript code then it works. Commented Feb 23, 2016 at 0:02

2 Answers 2

1

That's because you are not loading the jQuery plugin!!

You need to load this script:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
Sign up to request clarification or add additional context in comments.

Comments

0

For Bootstraps javascript components you will need to use jQuery.

You have to include jQuery before the Bootstraps scripts. Best is, you include both scripts at the bottom of your page, right before the closing </body> tag like:

[...your html...]

<!-- jQuery -->
<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>

</body>
</html>

1 Comment

For some reasons, the jQuery you sent is not working, but @BigDropGR works fine. Thanks for the help though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.