Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6605187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:15:15+00:00 2026-05-25T19:15:15+00:00

I really don’t understand why that piece of code won’t work : $$(‘.nav_contact’).addEvent(‘click’, function(){

  • 0

I really don’t understand why that piece of code won’t work :

$$('.nav_contact').addEvent('click', function(){  
    if (this.getStyle('color') != '#ffc000') {
        this.tween('color','#ffc000');
        alert(this.className);
        $$('.navigation').getElements('a').each(function(a) {
            alert(a.className);
            if (a.className != 'nav_contact') {
                a.tween('color','#b2b1af');
            }
        });
    }
});

here is the related HTML :

<nav class="navigation">
            <ul>
                <li><a class="nav_foo">Portfolio</a></li>
                <li><a class="nav_bar">Services</a></li>
                <li><a class="nav_contact">Contact</a></li>
            </ul>
            </nav>

This is supposed to highlight the clicked button and to somehow hide the other ones. The problem is that I can’t get elements className soon as I enter the each. The alert gives me “undefined”.
Anybody ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:15:15+00:00Added an answer on May 25, 2026 at 7:15 pm

    this will be hard to scale / pattern as is.

    consider something like this:

    (function() {
        var navItems = $$(".navigation a");
    
        document.getElements("a.nav_contact").addEvent("click", function() {
            var self = this;
            if (this.getStyle('color') != '#ffc000') {
                this.tween('color', '#ffc000');
    
                navItems.each(function(a) {
                    // more scalable - change all but the current one w/o special references.
                    if (a != self) {                      
                        a.tween('color', '#b2b1af');
                    }
    
                    return;
                    // or check if it has an implicit class name...
                    if (!a.hasClass("nav_contact"))
                        a.tween('color', '#b2b1af');
    
                    // or check if the only class name is matching...
                    if (a.get("class") != 'nav_contact')
                        a.tween('color', '#b2b1af');
    
    
                });
            }
        });
    })();
    

    jsfiddle: http://jsfiddle.net/dimitar/V26Fk/

    To answer your original question though. Even though CURRENTLY mootools returns a proper element object, it will not always be the case. Do not assume it will be and ALWAYS use the api to get properties of the object, eg. element.get("class") vs el.className – it does the browser differences mapping as well. same for value, text etc – just discipline your self to use the API or you wont be able to upgrade to mootools 2.0

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I really don't understand why this function doesn't work: function GetNomRepertoireTemporaire:WideString; var PathLocal :
I use this code to get Server Date but I really don't understand.CreateDateTime() is
I really don't understand what I'm doing wrong, but according to Adobe, this is
This is one of things that I really don't get. I know that it's
I really don't understand this. I downloaded the recent version of xCode 3.2.5 and
I really don't understand Javascript. In PHP, I can remove quotes like this: $tags_array
Which is something I really don't understand: I see nothing which actually makes this
I really don't understand the fascination with XHTML strict. Inline JavaScript typically requires a
I really don't understand regular expressions and was wondering what the following regular expressions
I am re-designing an application for a ASP.NET CMS that I really don't like.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.