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 8170933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:17:51+00:00 2026-06-06T21:17:51+00:00

There are 10 li elements and 5 of those have a element inside. And

  • 0

There are 10 li elements and 5 of those have a element inside. And I’d like to add an event on the li elements using Mootools.

A class has few variables and method including the event for the li elements and my problem comes from here. please see the event for li below,

li.addEvents({
    mouseover: function(e){
        console.log(this.id + ' / ' + this.classVar);
    }.bind(this)
});

In the event I need to refer li itself and a class variable because each li has unique id and the classVar has also information. But problem is if I use bind(this) to the event, this.id won’t work or if not using it, *this.classVar’ won’t work.

If I use e.target.id instead of this.id, it returns correct id IF ONLY the li doesn’t have a element. Otherwise e.target refers the a element.

Can anyone help me on this please? Many thanks in advance

  • 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-06-06T21:17:53+00:00Added an answer on June 6, 2026 at 9:17 pm

    The simplest way is to use the self or me workaround, like so…

    function myClass()
    {
        var self = this;
        this.classVar = 'foo';
    
        // some other code
    
        li.addEvents({
            mouseover: function(e){
                console.log(this.id + ' / ' + self.classVar);
            }
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to parse xml files that have elements like these: <element>&amp</element> <element>&amp;</element> But
Inside an xs:complexType, there are elements: Running .NET tools like SvcUtil.exe, you will get
I have some forms and I would like to add classes to the elements.
I have these elements, and I need to select the li inside the ul
i have a json file with many elements like these: { code : hfuiew89,
I have an array with 16 elements. I would like to evaluate these to
I am trying to unbind all event handlers for all elements that are inside
I am creating a few layouts with the root element being merge . inside
In my HTML there are a lot of elements. Some div elements have an
I have a couple of variables that need to be assigned inside a for

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.