Hi guys I am facing this problem very often I dont know the reason. Can any tell this why.
My Problem is, I am jsut new to the prototype. When I made a prototype file like this
[HTML]<html>
<head>
<script src="prototype. js"></script>
$('myButton').o bserve('click', function(){aler t('I am Clicked')});
</script>
</head>
.
..
...
some code
<input type="button" id="myButton" value="click Me">
.
..
...
some code
</html>[/HTML]
If i execute the code it is not working. But if i replace the code like this
[HTML]<html>
<head>
</head>
.
..
...
some code
<input type="button" id="myButton" value="click Me">
.
..
...
some code
</html>
<script src="prototype. js"></script>
$('myButton').o bserve('click', function(){aler t('I am Clicked')});
</script>[/HTML]
It is working. I want to know the reason why it is not working when the script is within the head. If any one knows the reason please answer it. It will help me a lot in developing myself.
Regards
Ramanan Kalirajan
My Problem is, I am jsut new to the prototype. When I made a prototype file like this
[HTML]<html>
<head>
<script src="prototype. js"></script>
$('myButton').o bserve('click', function(){aler t('I am Clicked')});
</script>
</head>
.
..
...
some code
<input type="button" id="myButton" value="click Me">
.
..
...
some code
</html>[/HTML]
If i execute the code it is not working. But if i replace the code like this
[HTML]<html>
<head>
</head>
.
..
...
some code
<input type="button" id="myButton" value="click Me">
.
..
...
some code
</html>
<script src="prototype. js"></script>
$('myButton').o bserve('click', function(){aler t('I am Clicked')});
</script>[/HTML]
It is working. I want to know the reason why it is not working when the script is within the head. If any one knows the reason please answer it. It will help me a lot in developing myself.
Regards
Ramanan Kalirajan
Comment