Ayhan Er Ayhan Er - 3 years ago 144
CSS Question

jQuery does not work for navbar in Materialize CSS

I am trying to use the jQuery load () method to make a Master Page.
This is the main HTML and Jquery code block.



$("#nav-wrapper").load("untitled2/navbar.html");

<body>
<nav id="nav-wrapper"></nav>
</body>





The code in the page where the navbar is locatedt


<body>
<div class="nav-wrapper">
<a href="#!" class="brand-logo">Logo</a>
<ul id="nav-mobile" class="right">
<ul id="dropdown2" class="dropdown-content">
<li><a href="#!"> <i class="small material-icons">add</i>K. Adi </a></li>
</ul>
<a class="btn dropdown-button" href="#!"
data-activates="dropdown2">DROPDOWN<i class="material-icons right">arrow_drop_down</i></a>
</ul>
</div>
</body>




But this is the result.
Dropdown and logo do not appear.
enter image description here

Answer Source

The problem is the address jQuery went to for the loading.

$("#nav-wrapper").load("untitled2/navbar.html");
Change this code this way.

$("#nav-wrapper").load("../untitled2/navbar.html");

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download