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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:23:11+00:00 2026-06-08T01:23:11+00:00

Am a little confused about the javascript object,say I have the DOM below <div

  • 0

Am a little confused about the javascript object,say I have the DOM below

<div class='of'></div>
<div class='of'></div>
<div class='of'></div>
<div class='of'></div>

 //select all of them 
  var fof = $('.of')

So fof is an array with 4 DOM object right? Can I treat the fof as javascript object ,and define some method like:

fof = {
  open:function(){

   }
 }

And is it possible to define some ‘action’ for fof; like click dblclick, so when the ‘action’ happens (like a event handler),call some method! in steady of hard coding

fof.click(function(){

})

How can I do that?

  • 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-08T01:23:13+00:00Added an answer on June 8, 2026 at 1:23 am

    Ok, first the basics. In Javascript, functions are first class objects. That means that you can do:

    var foo = function() { return 1 + 1;};
    

    the same way you can do:

    var foo = 5;
    

    In Javascript, all true objects (pretty much everything except primitives) have properties. These properties can be set to anything that a variable can be set to:

    var foo = {};
    foo.bar = function() { return 1 + 1; }
    foo.baz = 5;
    

    Whenever you see a method being used on an object, you’re just seeing the function that was set as a property being run.

    Since the jQuery results object (eg. $('.of')), which by the way is more than just an array, is a Javascript object, it can have properties, and those properties can be functions. So you absolutely can do:

    var fof = $('.of')
    fof.foo = function() { return 1 + 1; };
    fof.foo();
    

    Finally, you asked about making your own jQuery-like events. This is very easy to do using jQuery. Here’s a quick example:

    var fakeObject = {};
    fakeObject.fakeMethod = function() {
        // do something 
        $.trigger(this, 'myFakeClick');
    }
    
    var fakeObjectWatcher = {}
    fakeObjectWatcher.react = function() { alert('someone did something'); };
    $(fakeObject).on('myFakeClick', fakeObjectWatcher.react);
    
    fakeObject.fakeMethod(); // triggers myFakeClick event
    // fakeObjectWatcher will now alert "someone did something"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a little confused about Accept-Encoding . I have Web Service which would
I'm getting a little confused about bubbling. <html> <body> <div onclick=window.location='http://www.yahoo.com';> <span> <h3 onclick=window.location='http://www.google.com';>
I am a little bit confused about how javascript and the jquery lib works.
I'm a little confused about CSS and the class attribute. I always thought, the
I'm a little confused about how EGit workes. I have an existing git repository
I'm a little confused about how C++ handles includes. I have something like: typedef
I am little confused about the folder structure for my project and grouping them
I am a little confused about overloading rules, let's say there are following literal
I'm a little confused about the Swing painting model. Suppose that I have a
Am a little confused about how subversion model works. So say me and my

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.