Bonbin Bonbin - 1 year ago 67
CSS Question

Jquery click listener not firing (html,css,jquery)

I have this script in the head of the html:

<script src="">
$(function () {

which should fire when:

<img class="nav-toggle" src="static/images/menunav.png" style="cursor: pointer;">

this image is clicked.

and toggle the subclass open in:

<ul class="text mainnav">
<li>About me</li>

But it wont fire the .open class? What am i doing wrong here (first time jquery user).


.nav-toggle {
float: right;
margin-right: 70px;

position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #222;
text-align: center;
list-style: none;
display: inline-block;
transform: translateX(-100%);
transition: transform 0.6s ease;
} {
transform: translateX(50%);

Answer Source

I guess the problem is in the html. Try to split

<script src="[JQuery CDN]"></script>
$(function(){ ... });
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download