Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Passing the result of a function to onmouseover / onmouseout

    I have the following functions:

    function a()
    {
    var d
    d="this.style.backgroundColor='#0f0'";
    return d
    }

    function b()
    {
    var d
    d="this.style.backgroundColor='#00f'";
    return d
    }

    Then, inside my page, I have some divs elements that I would like to assign the onmouseover / onmouseout event with the result of the functions as arguments:

    <div id="menu_bi" onmouseover="a()" onmouseout="b()">Item 1</div>


    Can this be done? Haven't work for me yet.

    Thanks,

    Ignacio

  • #2
    Regular Coder
    Join Date
    Oct 2004
    Posts
    168
    Thanks
    0
    Thanked 5 Times in 5 Posts
    Change your function to this:

    function a(elem)
    {
    var d
    d=elem.style.backgroundColor='#0f0';
    return d
    }

    function b(elem)
    {
    var d
    d=elem.style.backgroundColor='#00f';
    return d
    }

    Change your HTML to this:

    <div id="menu_bi" onmouseover="a(this)" onmouseout="b(this)">Item 1</div>

  • #3
    New to the CF scene
    Join Date
    Jan 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks a lot, that did the trick!

    Ignacio


  •  

    Posting Permissions

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