Actually, when you click a picture, the menu changes, but the menu doesn’t work back after the second click.

function openm() { if (this.src = '/menu-icon.png') { jQuery('.navbar-brand').css('visibility','visible'); jQuery('.site-header-menu').css('visibility','visible'); jQuery('.meun').attr('src','/x.png'); } else { jQuery('.navbar-brand').css('visibility','hidden'); jQuery('.site-header-menu').css('visibility','hidden'); jQuery('.meun').attr('src','/menu-icon.png'); } } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> 

  • html forgot to add to the question - DogeDev

1 answer 1

It's very simple, you have an error in the condition if. Now you assign this.src to the value '/menu-icon.png', the result is true . The second time you click, the same thing happens and the result is the same. Need to:

 if (this.src == '/menu-icon.png') {