SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot nicc9's Avatar
    Join Date
    Jan 2005
    Location
    New Orleans, LA
    Posts
    181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    execute function only once

    hi, all.

    i got this function that needs to be triggered onMouseOver.


    however, the function keeps getting executed forever until one doesn't leave the onMouseOver spot.

    is there a way to trigger a function onMouseOver without having it keep execute?

    thanks, any help appreciated.

  2. #2
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    onmouseover triggers only once, on what are you using the onmouseover event?

    Follwing code shows that it will only trigger once:
    Code:
    <div id="b" style="width:50px; height:50px; background:red;"></div>
    <input type="text" id="output">
    <script>
    var i = 0;
    
    document.getElementById("b").onmouseover = function(){
    	document.getElementById("output").value = i++;
    }
    </script>

  3. #3
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perhaps mouseovers on descendant elements are triggering it.

    Check out isMouseLeaveOrEnter
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •