Link to home
Start Free TrialLog in
Avatar of sniger
sniger

asked on

javascript simple question

why when I put javascript code into <head> section , it is not working, only when I
put it into body section:

<head>


 /* read jquery etc */

</head>
<body>


<select>
 <option> 1 </option>
 <option> 2 </option>
  
</select>
 
 <script>

	
 $("select").change(function() {

 	 

 	var sel	=	$(this).val();

 	if  (sel != 0 )
 	{
 	 		
	}		

	});  			


</script> 

</body>
</html>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi  sniger,

JavaScript writes into the HTML <body> while the page loads.

Please check this link.

http://www.w3schools.com/js/js_howto.asp