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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:08:31+00:00 2026-06-09T17:08:31+00:00

I have this event handler: //Event Handler var bindEvt = (function () { use

  • 0

I have this event handler:

//Event Handler
var bindEvt = (function () {
    "use strict";
    if (document.addEventListener) {
        return function (element, event, handler) {
            element.addEventListener(event, handler, false);
        };
    }
    return function (element, event, handler) {
        element.attachEvent('on' + event, handler);
    };
}());

And this code which cycles trough menu elements and detects if one is clicked.

// Ajax article loading
function test(){var menuitem = document.getElementsByTagName('nav')[0].childNodes;
    for(var i= 0; i < menuitem.length; i++){
        bindEvt(menuitem[i], "click", loadajax);
    }
};

function loadajax () {
    alert('yo')
}
bindEvt(window, "load", test);

Now my problem is that I would like loadajax() to know what item was clicked but I cannot seem to figure out how to pass an argument from test() to loadajax().

How would I do this? I tried a couple of things but it always seems to break the script 🙁

Thanks for your feedback!

  • 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-09T17:08:32+00:00Added an answer on June 9, 2026 at 5:08 pm

    If all you’re trying to do is to know which object was clicked, then you can use the value of this in your event handler. You don’t have to pass that to loadajax. The event system will set this to the object that caused the event. You can also reference event.target.

    function loadajax (event) {
        event = event || window.event;   // deal with old IE
    
        // `this` points to the object that caused the event
    
        alert('yo');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this event listener: input_1.addEventListener('input',function(){ updateFromInput(1); },false); It controls the location of a
I have an event handler set up using plain javascript like this: myElement.addEventListener('drop', handleDrop,
I have this canvas mousedown event: $('#canvas').mousedown(function(e) { var coords = canvas.getMousePos(e); // user
If I have append a click event handler function to my Raphael element like
I have used this code in the past function getRand(){ return Math.round(Math.random()*(css.length-1)); } var
I have an Raphael element with click event handler: var paper = Raphael(container, 770,
I have this code for an event handler: rbM.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton
I have this code in a xaml file now in a event handler code
I have this exact issue ASP.net can’t update page from event handler and it's
I have this code : class Event{}; class CustomEvent:public Event{}; class Handler { public:

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.