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

  • Home
  • SEARCH
  • 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 7592683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:58:17+00:00 2026-05-30T20:58:17+00:00

How to bind event to element in pure javascript: This is what JQuery does,

  • 0

How to bind event to element in pure javascript:

This is what JQuery does, how do you accomplish it with pure javascript?

$('#arrow_left')
 .bind('click', {'c_index': c_index - item_limit }, 
  function(e)
  {
   var r = e.data.c_index; 
  }
  • 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-30T20:58:18+00:00Added an answer on May 30, 2026 at 8:58 pm

    You would use element.AddEventListener

    target.addEventListener(type, listener[, useCapture]);
    

    And in IE’s case (prior to IE9) you would use attachEvent.

    bSuccess = object.attachEvent(the_event, function_handler)
    //the_event always starts with "on"
    

    Like this:

    <input id="btn" type="button" value="click me" />​​​​​​​​​​​
    

    JS:

    function click_handler()
    {
        alert("clicked");
    }
    var el = document.getElementById("btn");   
    if(el.addEventListener)//check if this exists
    {
        el.addEventListener("click", click_handler);   
    } else {
        //then we're on IE older than 9
        el.attachEvent("onclick",click_handler);
    }​
    

    See the demo:
    http://jsfiddle.net/E8nYr/2/

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

Sidebar

Related Questions

I can bind a jquery event to this element like: <script type=text/javascript> $('#new_key').ready(function() {
I bind two event handlers on this link: <a href='#' id='elm'>Show Alert</a> JavaScript: $(function()
With this code, I'm trying to dynamically bind a click event to an element
I bind to a link (by using the .live() function of jQuery) click event
Consider the following code, in theory the click event should bind to each element
In jquery an event hadler's binding is the event generating DOM element (this points
If I bind an event to a DOM element, does the event ever get
I want to bind an event to a jQuery element so it calls a
After a bind a method to an event of a Tkinter element is there
i have an input element, and i want bind both change and keypress event

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.