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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:01:46+00:00 2026-05-27T02:01:46+00:00

Possible Duplicate: What does jQuery.fn mean? I have some script on a page trying

  • 0

Possible Duplicate:
What does jQuery.fn mean?

I have some script on a page trying to work out what its doing:

(function ($, window, undefined)
{

    var 
    // String constants for data names
    dataFlag = "watermark",
    dataClass = "watermarkClass",
    dataFocus = "watermarkFocus",
    dataFormSubmit = "watermarkSubmit",
    dataMaxLen = "watermarkMaxLength",
    dataPassword = "watermarkPassword",
    dataText = "watermarkText",

    // Copy of native jQuery regex use to strip return characters from element value
    rreturn = /\r/g,

    // Includes only elements with watermark defined
    selWatermarkDefined = "input:data(" + dataFlag + "),textarea:data(" + dataFlag + ")",

    // Includes only elements capable of having watermark
    selWatermarkAble = "input:text,input:password,input[type=search],input:not([type]),textarea",

    // triggerFns:
    // Array of function names to look for in the global namespace.
    // Any such functions found will be hijacked to trigger a call to
    // hideAll() any time they are called.  The default value is the
    // ASP.NET function that validates the controls on the page
    // prior to a postback.
    // 
    // Am I missing other important trigger function(s) to look for?
    // Please leave me feedback:
    // http://code.google.com/p/jquery-watermark/issues/list
    triggerFns = [
        "Page_ClientValidate"
    ],

    // Holds a value of true if a watermark was displayed since the last
    // hideAll() was executed. Avoids repeatedly calling hideAll().
    pageDirty = false,

    // Detects if the browser can handle native placeholders
    hasNativePlaceholder = ("placeholder" in document.createElement("input"));


    /*******************************************************/
    /* Enable / disable other control on trigger condition */
    /*******************************************************/
    $.fn.TriggerContol = function (options)
    {

Im struggling with the last two lines. Why has the developer used fn, what does this mean?

I understand that this whole file is basically a self invoking anonymous function designed to attach functions to the Jquery library so you can do jQuery(x).TriggerControl. Im just wondering what this particular construct means.

  • 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-27T02:01:47+00:00Added an answer on May 27, 2026 at 2:01 am

    In jQuery, jQuery.fn is simply a reference to jQuery.prototype.

    So to understand what is happening, you really need to understand prototypal inheritance.

    All objects created from the jQuery constructor will inherit any property that exists on the jQuery.prototype object.

    Take this simplified example:

    function jQuery() {
          // empty constructor function
    }
    
    jQuery.fn = jQuery.prototype;  // Make a "fn" property that simply references the 
                                   //    jQuery.prototype object.
    
    // So assigning a property to jQuery.fn 
    //    is the same as assigning it to jQuery.prototype
    jQuery.fn.sayHello = function() { alert( "Hi!" ); };
    
    // Create an object from the jQuery constructor
    var obj = new jQuery;
    
    // Our new object will automatically inherit the "sayHello" function
    obj.sayHello();  // "Hi!"
    

    This is obviously very simple, and jQuery does much more than just this, but it is the prototypal inheritance that allows all jQuery objects to have the same set of methods.

    To add a new method to all jQuery objects, you just add to its prototype.

    jQuery.fn.sayGoodbye = function() { alert("Goodbye!"); };
    
    // call the new method on our original object
    obj.sayGoodbye();  // Goodbye!
    

    As you can see, the sayGoodbye properly magically appeared, even though we didn’t directly add that property to our obj.


    JSFIDDLE DEMO of the above code.


    I would assume that the reason they offer jQuery.fn as a property is simply because it is shorter, and perhaps easier to understand for someone who doesn’t know how prototypal inheritance works.

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

Sidebar

Related Questions

Possible Duplicate: How does the Google Did you mean? Algorithm work? Suppose you have
Possible Duplicate: What does (function($) {})(jQuery); mean? For the function (function($){})(), I've seen it
Possible Duplicate: jQuery question: what does it really mean? For example, (function (exports, $,
Possible Duplicate: What does (function($) {})(jQuery); mean? I've seen a lot of jQuery code
Possible Duplicate: how does jquery chaining work? This is a normal thing you would
Possible Duplicate: What does this JavaScript/jQuery syntax mean? I specifically mean when you do
Possible Duplicate: In jQuery, what does $.fn. mean? Can someone explain the code below
Possible Duplicate: Blank out a form with jQuery I am using a jQuery function
Possible Duplicate: What does map(&:name) mean in Ruby? I was watching a railscast and
Possible Duplicate: What does ||= (or equals) mean in Ruby? It's hard to search

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.