Jquery in javascript not working for some reason

279
July 02, 2017, at 7:00 PM

I am trying to make a menu that comes in from the left and then the body moves. But for some reason my jQuery code won't work!

<script src="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> 
	<link src="jan.js"></link>

That's my html code. and my jQuery code in js is this:

var menu = function(){ 
	$("div.menu_icon img").click(function(){ 
		$(".Menu").animate({ 
			left: 'opx' 
		},200); 
		 
		$("body").animate({ 
			left: '285px' 
		},200); 
	}); 
} 
$(document).ready(main);

Answer 1

Main should be menu?

 $(document).ready(menu);
Answer 2

You don't include JS scripts using the <link> tag. Use <script src="..."> instead:

<!-- include jQuery -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<!-- include your script -->
<script type="text/javascript" src="path/to/your/javascript-file.js"></script>

Take a look at this StackOverflow question.

READ ALSO
Unable to get dropdown selected value from aspx page to backend

Unable to get dropdown selected value from aspx page to backend

Hello Guys i am using a web service and ajax call to bind my cascading drop down lists but i am not able to get the selected value of first drop down in code behind

278
How to get ids of checked checkboxes that are generated dynamically in jquery

How to get ids of checked checkboxes that are generated dynamically in jquery

My problem is that when i click on the button after checking some checkboxes, the result shows that, there is a loop problemthe id of the last checked box have been push into the array instead

229
Failed to construct async operation in node.js

Failed to construct async operation in node.js

I want to use parallel instead of waterfall to do an operation

346