Ricky Jaime
Ricky Jaime

Reputation: 63

Dropdown menu's will not drop down

I'm having trouble understanding why my dropdowns aren't working. They are copied directly from Bootstrap and should work. I suspect it has something to do with the jQuery/Bootstrap link tags but I'm not too sure.

Ordering the jQuery and Bootstrap links differently and entering different code. It just won't work when I open in browser.

<!DOCTYPE html>
    <html>
    <head>
    	<title>Review of things</title>
    
    	<meta charset="utf-8">
    
    	<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
    
    	<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
    
    	<link rel="stylesheet" type="text/css" href="review.css">
    
    
    </head>
    
    
    <body>
    
    <nav class="navbar navbar-expand-lg navbar-light bg-light">
      <a class="navbar-brand" href="#">Navbar</a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarNavDropdown">
        <ul class="navbar-nav">
          <li class="nav-item active">
            <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#">Features</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#">Pricing</a>
          </li>
          <li class="nav-item dropdown">
            <a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
              Dropdown link
            </a>
            <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
              <a class="dropdown-item" href="#">Action</a>
              <a class="dropdown-item" href="#">Another action</a>
              <a class="dropdown-item" href="#">Something else here</a>
            </div>
          </li>
        </ul>
      </div>
    </nav>
    
    <hr width="75%">
    
    <div class="container">
      <div class="row">
        <div class="col">
    	<ul>
    		<li>OnE</li>
    		<li>tWo</li>
    		<li>THrEe</li>
    	</ul>
    	</div>
    
    <div class="col">
    	<table border="2px" solid black>
    	 <thead>
    		<tr>
    				<th>Table</th>
    				<th>ROWS</th>
    				<th>ARE</th>
    				<th>COOOOL</th>
    		</tr>
    	 </thead>
    	 	<tbody>
    			<tr>
    				<td>BOO</td>
    				<td>words</td>
    				<td>for</td>
    				<td>TABLE</td>
    			</tr>
    
    			<tr>
    				<td>Yay words</td>
    				<td>Yay words</td>
    				<td>Yay words</td>
    				<td>Yay words</td>
    			</tr>
    			<tr>
    				<td>table data</td>
    				<td>table data</td>
    				<td>table data</td>
    				<td>table data</td>
    			</tr>
    
    		</tbody>
    	</table>
    
    </div>
    
    <div class="col">
    <form>
      <div class="form-group">
        <label for="exampleInputEmail1">Email address</label>
        <input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
        <small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
      </div>
      <div class="form-group">
        <label for="exampleInputPassword1">Password</label>
        <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
      </div>
      <div class="form-group form-check">
        <input type="checkbox" class="form-check-input" id="exampleCheck1">
        <label class="form-check-label" for="exampleCheck1">Check me out</label>
      </div>
      <button type="submit" class="btn btn-primary">Submit</button>
    </form>
    
    </div>
    </div>
    </div>
    </div>
    
    <div class="formcontain">
    <form>
      <div class="form-group" >
        <label for="exampleInputEmail1">Email address</label>
        <input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
        <small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
      </div>
      <div class="form-group">
        <label for="exampleInputPassword1">Password</label>
        <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
      </div>
      <div class="form-group form-check">
        <input type="checkbox" class="form-check-input" id="exampleCheck1">
        <label class="form-check-label" for="exampleCheck1">Check me out</label>
      </div>
      <button type="submit" class="btn btn-primary">Submit</button>
    </form>
    </div>
    
    <p>
    	Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    	tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    	quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    	consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    	cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    	proident, sunt in culpa qui officia deserunt mollit anim id est laborum.>
    
    </p>
    
    <hr>
    
    <h1>
    	This is an H1 line.
    </h1>
    
    </body>
    </html>

I expect the dropdown options to appear when page is fully expanded and when the page is xs for mobile view.

Upvotes: 1

Views: 73

Answers (1)

brooksrelyt
brooksrelyt

Reputation: 4025

You are missing the Bootstrap JavaScript add this CDN to your code below your jQuery:

https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.2.1/js/bootstrap.min.js

<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.2.1/js/bootstrap.min.js"></script>

Your code (you had an extra closing div and I moved the scripts to the bottom of your HTML):

<!DOCTYPE html>
    <html>
    <head>
    	<title>Review of things</title>
    	<meta charset="utf-8">
    	<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
    	<link rel="stylesheet" type="text/css" href="review.css">
    </head>
    
    <body>
    	<nav class="navbar navbar-expand-lg navbar-light bg-light">
    		<a class="navbar-brand" href="#">Navbar</a>
    		<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
    			<span class="navbar-toggler-icon"></span>
    		</button>
    		<div class="collapse navbar-collapse" id="navbarNavDropdown">
    			<ul class="navbar-nav">
    				<li class="nav-item active">
    					<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
    				</li>
    				<li class="nav-item">
    					<a class="nav-link" href="#">Features</a>
    				</li>
    				<li class="nav-item">
    					<a class="nav-link" href="#">Pricing</a>
    				</li>
    				<li class="nav-item dropdown">
    					<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    						Dropdown link
    					</a>
    					<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
    						<a class="dropdown-item" href="#">Action</a>
    						<a class="dropdown-item" href="#">Another action</a>
    						<a class="dropdown-item" href="#">Something else here</a>
    					</div>
    				</li>
    			</ul>
    		</div>
    	</nav>
    
    	<hr width="75%">
    
    	<div class="container">
    		<div class="row">
    			<div class="col">
    				<ul>
    					<li>OnE</li>
    					<li>tWo</li>
    					<li>THrEe</li>
    				</ul>
    			</div>
    
    			<div class="col">
    				<table border="2px" solid black>
    					<thead>
    						<tr>
    							<th>Table</th>
    							<th>ROWS</th>
    							<th>ARE</th>
    							<th>COOOOL</th>
    						</tr>
    					</thead>
    					<tbody>
    						<tr>
    							<td>BOO</td>
    							<td>words</td>
    							<td>for</td>
    							<td>TABLE</td>
    						</tr>
    
    						<tr>
    							<td>Yay words</td>
    							<td>Yay words</td>
    							<td>Yay words</td>
    							<td>Yay words</td>
    						</tr>
    						<tr>
    							<td>table data</td>
    							<td>table data</td>
    							<td>table data</td>
    							<td>table data</td>
    						</tr>
    
    					</tbody>
    				</table>
    
    			</div>
    
    			<div class="col">
    				<form>
    					<div class="form-group">
    						<label for="exampleInputEmail1">Email address</label>
    						<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
    						<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
    					</div>
    					<div class="form-group">
    						<label for="exampleInputPassword1">Password</label>
    						<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
    					</div>
    					<div class="form-group form-check">
    						<input type="checkbox" class="form-check-input" id="exampleCheck1">
    						<label class="form-check-label" for="exampleCheck1">Check me out</label>
    					</div>
    					<button type="submit" class="btn btn-primary">Submit</button>
    				</form>
    
    			</div>
    		</div>
    	</div>
    
    	<div class="formcontain">
    		<form>
    			<div class="form-group" >
    				<label for="exampleInputEmail1">Email address</label>
    				<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
    				<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
    			</div>
    			<div class="form-group">
    				<label for="exampleInputPassword1">Password</label>
    				<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
    			</div>
    			<div class="form-group form-check">
    				<input type="checkbox" class="form-check-input" id="exampleCheck1">
    				<label class="form-check-label" for="exampleCheck1">Check me out</label>
    			</div>
    			<button type="submit" class="btn btn-primary">Submit</button>
    		</form>
    	</div>
    
    	<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    
    	<hr>
    
    	<h1>This is an H1 line.</h1>
    
    <script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.2.1/js/bootstrap.min.js"></script>
    
    </body>
    </html>

Upvotes: 3

Related Questions