Jump to content

Need Help. Create Effects

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
9 replies to this topic

#1
Wyatt

Wyatt

    Newbie

  • Members
  • Pip
  • 6 posts
How can create rollover effects? Give me an example please. Would be very grateful for the assistance.

Edited by Wyatt, 15 August 2010 - 12:07 AM.


#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
rollover effects - Google Search

You may want to be more specific as to which effects you are talking about. There are CSS rollover effects, MooTools/jQuery effects, etc.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
Wyatt

Wyatt

    Newbie

  • Members
  • Pip
  • 6 posts
How can I optimize the code.

  

var item = document.getElementById(this.domElementId).childNodes;

for( var i = 0; i < item.length; i++ ) {

        item[i].onmouseover = function() {

              this.className = 'someClass';               

        }


       item[i].onmouseover = function() {

            this.className = '';   

        }

    }  

Not to cause an anonymous function?

#4
Guest_johnny.dacu_*

Guest_johnny.dacu_*
  • Guests
I think you need to assign onmouseout for one of those two. Now you assign the over event and then you rewrite it three lines bellow

#5
Wyatt

Wyatt

    Newbie

  • Members
  • Pip
  • 6 posts
As an example you can show please, because I do not much understand your point.

#6
Guest_johnny.dacu_*

Guest_johnny.dacu_*
  • Guests
var item = document.getElementById(this.domElementId).childNodes;
for( var i = 0; i < item.length; i++ ) {
        item[i].onmouseover = function() {
              this.className = 'someClass';               
        }

       [B]item[i].onmouseout = function[/B]() {
            this.className = '';   
        }
    }

Look at bold text

#7
Wyatt

Wyatt

    Newbie

  • Members
  • Pip
  • 6 posts
What we accomplish by removing onmouseout?
Still under 100 elements will create 100 functions, and also we can not manipulate onmouseout which should be a logic...

#8
Guest_johnny.dacu_*

Guest_johnny.dacu_*
  • Guests
I haven't said you shoud remove onmouseout. Look at your code. You have declared "item[i].onmouseover = function() {" twice.

#9
Wyatt

Wyatt

    Newbie

  • Members
  • Pip
  • 6 posts
I have for each element declared 2 events onmouseover, onmouseout.
So li onmouseover ='.......' onmouseout = '..........'

I can not understand what you mean....

Please give an example

#10
Wyatt

Wyatt

    Newbie

  • Members
  • Pip
  • 6 posts
This implementation will be optimal than the previous ?

        var element = null;

        var handlerOnMouseOver = function() {
            // some style
        }

        var handlerOnMouseOut = function() {
            //some style ....
        }

        for( var i = 0; i < item.length; i++ ) {
            element = item[i];
            element.onmouseover = handlerOnMouseOver;
            element.onmouseout = handlerOnMouseOut;
        }