I am currently learning to use java script, and have come across a problem I cant solve.
in a simple HTM for the sake of practice I have made an script that modifies the top margin of a div:
var boton = (function () {
var timerId;
return function (margin, element) {
var i = 2;
timerId = setInterval (function () {
if (i > margin)
i = 2;
element.style.marginTop = i + 'px';
i++;
}, 100);
}; }) ();
If I call the function this way it works:
<script type="text/javascript">
boton (50 , document.getElementById("botondiv"));
</script>
But if I try to call it within a mouseover event on an A tag it wont work
<a onmouseover="boton (50 , document.getElementById("botondiv"));" href="#"></a>
My idea on this is that when some one hovers over the A tag the top margin of the element is modified. what am I doing wrong?
Well, you have quotes inside quotes with no escaping, for one.
Should be: