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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:21:59+00:00 2026-05-15T13:21:59+00:00

How to correctly do something like the following without using jQuery. $(document).ready(function(){ $(#someButton).click(function(){ alert(Hello);

  • 0

How to correctly do something like the following without using jQuery.

   $(document).ready(function(){
      $("#someButton").click(function(){
        alert("Hello");
      });
   });

Thanks.

  • 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-15T13:22:00+00:00Added an answer on May 15, 2026 at 1:22 pm

    The easiest way is:

    // DOM Level 0 way
    window.onload = function () {
      document.getElementById("someButton").onclick = function() {
        alert("Hello");
      };
    };
    

    This will work on all browsers but note that with this approach only one event handler can be attached to an event.

    Also notice that the onload event is not completely equivalent to the jQuery’s ready event, onload will be fired when all the resources of the page are completely loaded (images, sub-frames, etc…), while ready fires as soon the DOM has been parsed.

    If you want to attach multiple event handlers, you can use the DOM Level 2 Standard element.addEventListerner method (or element.attachEvent for IE)

    The simplest abstraction to get a cross-browser way to bind events is:

    function addEvent(el, eventType, handler) {
      if (el.addEventListener) { // DOM Level 2 browsers
        el.addEventListener(eventType, handler, false);
      } else if (el.attachEvent) { // IE <= 8
        el.attachEvent('on' + eventType, handler);
      } else { // ancient browsers
        el['on' + eventType] = handler;
      }
    }
    

    Then you can:

    var button = document.getElementById("someButton");
    addEvent(button, 'click', function () {
      alert("Hello");
    });
    
    addEvent(button, 'click', function () {
      alert("world!");
    });
    

    Be aware also that the addEventListener and the IE’s attachEvent methods have their differences, when you attach multiple handlers to an event with addEventListener they will be fired in the same order, as the handlers were bound (FIFO), attachEvent will trigger the handlers in the contrary order (LIFO).

    Check an example here.

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

Sidebar

Related Questions

I am currently doing something like this: myFunc(tracer); function tracer(message:String):void{ trace(message); } function myFunc(callback:Function):void{
I'm trying to validate date using PHP. I'd like following formats to be valid:
I have something like this currently: <div class = className style = position: absolute;
currently i'm trying to do something like this: 1 cron job backup_daily 2 cron
I currently have a table structure that looks something like this(some details omitted): ColumnName
I currently have service classes that look something like this public class UserService :
Currently, I have something like: public partial class Form1 : Form { delegate void
I am currently trying to achieve something like this: Based on this class, I
Currently I have a site where it has a header that looks something like
I'd like to check if an element is being animated currently, something like $(...).is(':animated')

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.