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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:36:31+00:00 2026-05-15T10:36:31+00:00

Yeah so I’ve been messing around with javascript a while but only recently got

  • 0

Yeah so I’ve been messing around with javascript a while but only recently got into stuff like object orientation, prototyping and using objects for all functions and vars.

But, many frameworks like jQuery or extJS have something I have yet to grasp, you can define an object by using a built in function for searching the dom, example:

var a = $('#mydiv');

and then you can do a.click(function);

So my question is, how can I create a “framework” of sorts where I can write code in that style, like example:

var mydiv = document.querySelector('mydiv');
mydiv.neph(args,args);

So I have my object defined, in this case it’s a dom element or whatever, now I pass it to my function “neph” with arguments, I want to create code that allows me to do this. But since mydiv does not have any function, it only has in this case the dom element right so mydiv.neph does not exist, but in jquery you can define whatever var and .click or .mouseover or whatever does exists within the object as functions? Confusion ensues! 😀

Ok sorry if this is a retarded question btw =P

  • 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-15T10:36:32+00:00Added an answer on May 15, 2026 at 10:36 am

    jQuery and other libraries define a function called $ that takes several optional parameters. The object returned by calling $ is not a DOM element, but a jQuery object wrapping a DOM element up with a set of convenient functions.

    You can do something similar yourself:

    <html>
       <body>
          <input id="derp" type="text"/>
    <script type="text/javascript">
    
    function $(id)
    {
       return new myLibrary(id);
    };
    
    function myLibrary(id)
    {
       this.el = document.getElementById(id);
    };
    
    myLibrary.prototype.help = function()
    {
       alert(this.el.id);
       return this;
    };
    
    // Woah! My own fake jquery!
    $("derp").help();
    </script>
    
       </body>
    </html>
    

    jQuery is far more sophisticated, of course. For example, it will use apply and call to set this correctly in calls like jQuery.each.

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

Sidebar

Related Questions

Yeah, there are numerous questions like How to turn a String into a javascript
Yeah I know that SQL Server has got free express editions(2005/2008) But what i
I'm making my own javascript-based programming language (yeah, it is crazy, but it's for
Yeah, yeah, I know, strict mode ain't around yet, but really, I'm planning for
So yeah, I'm gettin' into this testing thing! But I don't know what to
Yeah, so question looks like I'm kidding, but it turns out that there are
Yeah so ive tried lots of stuff but the output keeps coming out all
Yeah this works in FF and Chrome, but for some reason wont work in
Yeah, looks insane, but let me explain better. When in Jquery we use for
So yeah, like I said, I've spent a few hours trying to fix this

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.