Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old November 17th, 2006, 12:35 AM
Koncept
Guest
 
Posts: n/a
Default Help with prototype and scriptaculous


Hey folks. I just want to say that I am not much of a javascript
developer and I could really use a hand getting something working...

Basically, I have a set of <divelements, each with a class of
"button". Like so:

<div class="button" style="display:none">
<a href="#"><img src="button.gif" /></a>
</div>

I want to do the following:

1) When the page loads, detect each div element and fade it in to 50%
opacity
2) bind two event watchers to the divs elements ( mouseover, mouseout )

on mouseover, I want the divs to increase to 100% opacity and on
mouseout, decrease back to 50%.

I have the following code right now, but it doesn't seem to be a smooth
transition of events until I mouseover the divs for the second time (
the first run is a bit jittery).

I put this together using code I found from here and there, so if it's
kludge, please help me correct it.

window.onload = function(){
var btnObjs = document.getElementsByClassName( 'button' );
for (var i=0; i < btnObjs.length; i++) {
var cntlD = btnObjs[i];
new Effect.Appear(cntlD,{from:0,to:0.5});
Event.observe( cntlD, 'mouseover', function(){new
Effect.Appear(this,{from:0.5,to:1.0})}, false);
Event.observe( cntlD, 'mouseout', function(){new
Effect.Fade(this,{from:1.0,to:0.5})}, false);
}
}

--
Koncept <<
"The snake that cannot shed its skin perishes. So do the spirits who are
prevented from changing their opinions; they cease to be a spirit." -Nietzsche
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,248 network members.