Options

hey javascripters I need your help

Mike LaneMike Lane Registered Users Posts: 7,106 Major grins
edited September 13, 2005 in SmugMug Support
Say I had this in the html:

<div id="navcontainer">
<ul id="navbar">
<li><a href="#">link1</a></li>
<li><a href="#">link2</a></li>
<li><a href="#">link3</a></li>
</ul>
</div>

<div class="swap"></div>

What I'd like to do is when I rollover the link1, link2, and link3 class in the lower div to change from swap to say swap1, swap2, or swap3 respectively. I'm pretty sure that it'll take an onmouseover / onmouseout event I just don't know how to access the swap class.
Y'all don't want to hear me, you just want to dance.

http://photos.mikelanestudios.com/

Comments

  • Options
    flyingdutchieflyingdutchie Registered Users Posts: 1,286 Major grins
    edited September 12, 2005
    Mike Lane wrote:
    Say I had this in the html:

    <div id="navcontainer">
    <ul id="navbar">
    <li><a href="#">link1</a></li>
    <li><a href="#">link2</a></li>
    <li><a href="#">link3</a></li>
    </ul>
    </div>

    <div class="swap"></div>

    What I'd like to do is when I rollover the link1, link2, and link3 class in the lower div to change from swap to say swap1, swap2, or swap3 respectively. I'm pretty sure that it'll take an onmouseover / onmouseout event I just don't know how to access the swap class.
    Here is an example:
    <div id="navcontainer"> 
    <ul id="navbar">
    <li><a href="#" swapclass="swap1"
    	 onmouseover="doMouseOver(this);"
    	 onmouseout="doMouseOut(this);">
    	link1</a></li>
    <li><a href="#" swapclass="swap2" 
    	 onmouseover="doMouseOver(this);"
    	 onmouseout="doMouseOut(this);">
    	link2</a></li>
    <li><a href="#" swapclass="swap3" 
    	 onmouseover="doMouseOver(this);"
    	 onmouseout="doMouseOut(this);">
    	link3</a></li>
    </ul>
    </div>
     
    <div id="my_swap" class="swap"></div>
    
    Then you have this javascript function:
    function doMouseOver(pLinkElm) 
    {
    	var swapClass = pLinkElm.swapclass;
    	// or var swapClass = pLinkElm.getAttribute("swapclass");
    	document.getElementById("my_swap").className = swapClass;
    }
    
    For the onmouseout, you would call a similar function:
    function doMouseOut(pLinkElm) 
    {
    	document.getElementById("my_swap").className = "swap";
    }
    
    That's it.:)

    There may be syntax errors in the above scripts, but you'll get the idea :):
    Finally i get to be of some help for you, Mike. As thanks for all the help you've given me! <img src="https://us.v-cdn.net/6029383/emoji/thumb.gif&quot; border="0" alt="" >
    -- Anton.
    I can't grasp the notion of time.

    When I hear the earth will melt into the sun,
    in two billion years,
    all I can think is:
        "Will that be on a Monday?"
    ==========================
    http://www.streetsofboston.com
    http://blog.antonspaans.com
  • Options
    Mike LaneMike Lane Registered Users Posts: 7,106 Major grins
    edited September 12, 2005
    Sweet thanks!
    Y'all don't want to hear me, you just want to dance.

    http://photos.mikelanestudios.com/
  • Options
    flyingdutchieflyingdutchie Registered Users Posts: 1,286 Major grins
    edited September 13, 2005
    Mike Lane wrote:
    Sweet thanks!
    No problem! I'll be putting some more of my javascript on this forum later, some functions that may come in handy for styling galleries.
    I can't grasp the notion of time.

    When I hear the earth will melt into the sun,
    in two billion years,
    all I can think is:
        "Will that be on a Monday?"
    ==========================
    http://www.streetsofboston.com
    http://blog.antonspaans.com
  • Options
    Mike LaneMike Lane Registered Users Posts: 7,106 Major grins
    edited September 13, 2005
    No problem! I'll be putting some more of my javascript on this forum later, some functions that may come in handy for styling galleries.
    We could always use a javascript sticky to go along with the CSS sticky.
    Y'all don't want to hear me, you just want to dance.

    http://photos.mikelanestudios.com/
Sign In or Register to comment.