Dropdown in the navbar

Asked

Viewed 140 times

1

I need a force here for a problem that’s killing me.

I can’t get action on dropdown in my navbar. I am using Bootstrap 4.0 and jQuery 3.2.1. Follow my codes:

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" rel="stylesheet"/>

<nav class="navbar navbar-light bg-light">

	<a class="navbar-brand" href="publicidade.php">
		<img src="img/home.png" width="30" height="30" class="d-inline-block align-top" alt="">
		Inicio
	</a>
	<a class="dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
		Dropdown
	</a>
	<div class="dropdown-menu" aria-labelledby="navbarDropdown">
		<a class="dropdown-item" href="#">Action</a>
		<a class="dropdown-item" href="#">Another action</a>
		<div class="dropdown-divider"></div>
		<a class="dropdown-item" href="#">Something else here</a>
	</div>
	<a class="navbar-brand" href="relatorioChamados.php">
		<img src="img/consultar.png" width="30" height="30" class="d-inline-block align-top" alt="">
		Relatórios Chamados
	</a>
	<a class="navbar-brand" href="sair.php">
		<img src="img/off.png" width="30" height="30" class="d-inline-block align-top" alt="">
		Sair
	</a>
</nav>

<script>
	$(function()){
		$('.dropdown-toggle').dropdown();
	}); 
</script>

1 answer

1


There was an error in where it was closed to function(), that is, a needless parenthesis the correct is in the example below:

$(function(){
		$('.dropdown-toggle').dropdown();
	});
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.min.js" integrity="sha384-a5N7Y/aK3qNeh15eJKGWxsqtnX/wWdSZSKp+81YjTmS15nvnvxKHuzaWwXHDli+4" crossorigin="anonymous"></script>
<nav class="navbar navbar-light bg-light">

	<a class="navbar-brand" href="publicidade.php">
		<img src="img/home.png" width="30" height="30" class="d-inline-block align-top" alt="">
		Inicio
	</a>
	<a class="dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
		Dropdown
	</a>
	<div class="dropdown-menu" aria-labelledby="navbarDropdown">
		<a class="dropdown-item" href="#">Action</a>
		<a class="dropdown-item" href="#">Another action</a>
		<div class="dropdown-divider"></div>
		<a class="dropdown-item" href="#">Something else here</a>
	</div>
	<a class="navbar-brand" href="relatorioChamados.php">
		<img src="img/consultar.png" width="30" height="30" class="d-inline-block align-top" alt="">
		Relatórios Chamados
	</a>
	<a class="navbar-brand" href="sair.php">
		<img src="img/off.png" width="30" height="30" class="d-inline-block align-top" alt="">
		Sair
	</a>
</nav>

  • 1

    Puts guy who falters, thank you!!!

  • @Gabrielbarreto if useful could accept as an answer

Browser other questions tagged

You are not signed in. Login or sign up in order to post.