i can't understand why this code works well
but the code below no.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script type="text/javascript">
$('#enviar').click(function(){
alert ("casd");
});
</script>
</head>
<body>
<input type="submit" id="enviar" value="Registo" />
</body>
</html>
what is the reason?
onLoad. That means the JavaScript code is executed after the whole page loaded. Your code is the same as selectingno wrap (head)and you will see that it won't work either.