Search code examples
javascripthtmlmarquee

Calling javascript function on onMouseOut


I wrote the following code, for marquee: In which I want on mouse-over, a function will get called

<marquee class="smooth_m" behavior="scroll" direction="left" scrollamount="3">
  <span style="float:left; padding:0 20px 0 0;" onMouseOut="loadStart()" onMouseOver="loadStop()">testing</span>
</marquee>
<script type="text/javascript">
loadStop()
{
alert("loadStop");  
}
loadStart()
{
alert("loadStart"); 
}
</script>

but it's not loading the respective functions in span like, onMouseOut it should load loadStart and so on.. Can someone help in this?


Solution

  • Working demo http://jsfiddle.net/CTQVr/ or on mouse over stop marquee like this: http://jsfiddle.net/CTQVr/4/

    issues was: function missing from your function name.

    Hope this helps,

    HTML

    <marquee class="smooth_m" behavior="scroll" direction="left" scrollamount="3">
      <span style="float:left; padding:0 20px 0 0;" onmouseout="loadStart()" onmouseover="loadStop()"> testing</span>
    </marquee>
    
    ​
    

    jquery code

    function loadStop() {
        alert("loadStop");
    }
    
    function loadStart() {
        alert("loadStart");
    }​
    

    Update to stop on mouseover

    $("marquee").hover(function () { 
        this.stop();
       // loadStop();
    }, function () {
        this.start();
       // alert("loadStart");
    });
    ​