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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:07:44+00:00 2026-05-26T19:07:44+00:00

jQuery has functions like .on() and .trigger() that let you attach events to DOM

  • 0

jQuery has functions like .on() and .trigger() that let you attach events to DOM objects and then manually trigger those events. The documentation for these functions specifically refers to events on “elements”, which I take to mean HTML/DOM elements.

Can I also use these functions to add event functionality to plain old JavaScript objects?

var x = {};
$(x).on('bonk', function() { alert('Oif!'); });
$(x).trigger('bonk'); // shows the alert

This works in all the browsers I’ve tested it in (Chrome 15, FireFox 7, IE 9, and Opera 11.52, all on Windows), which seems promising. But it’s not clear from the documentation whether it’s actually meant to be a supported scenario, in all browsers, on all platforms. The docs’ choice of terminology (“elements”) casts a lot of doubt.

The docs do state that I can make up my own event names (for example, the doc page for .on() has an example to “Attach and trigger custom (non-browser) events”). But still, that’s always attaching the event to a DOM element, not a plain old object.

Is there anything that definitively states whether jQuery supports .on() and .trigger() with plain old JavaScript objects?

  • 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-26T19:07:45+00:00Added an answer on May 26, 2026 at 7:07 pm

    Looking at the source code I found some hints that it’s intended but then I also found this:

    No particular reason why it’s not documented (other than that it’s
    rather non-traditional for most users) – but yes, we support it and
    have unit tests for it.

    http://forum.jquery.com/topic/triggering-custom-events-on-js-objects

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

Sidebar

Related Questions

Jquery has a great language construct that looks like this: $(document).ready(function() { $(a).click(function() {
I'm using a jQuery plugin that has its functions defined as such: $('#mydiv').pluginAction({ someproperty:
I have a simple JavaScript file that has three jQuery $document.ready functions. All three
The Facebook JS SDK has the equivalent of jQuery's trigger() function, FB.Event.fire that allows
I have a jquery menu that has so many entries that it extends further
If a page has both JQuery and Prototype then I got conflict. There is
I created a page that has a JQuery based dialog using the standard JQuery
I'm using javascript and jQuery. I have a problem that my web app has
So, I'm coding up a site that has certain events triggering as you scroll
JQuery has great support for custom events - .bind(foo, function(e)... . However what if

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.