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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:48:46+00:00 2026-05-16T04:48:46+00:00

How can I create a jQuery function like $.MyFunction(/*optional parameter*/)? which will return a

  • 0

How can I create a jQuery function like

$.MyFunction(/*optional parameter*/)?

which will return a bool?

note:

I’ve tried this:

jQuery.fn.isValidRequest = function (options) {

    return true;
}

// I'm contending with Prototype, so I have to use this    
jQuery(document).ready(function ($) {    

    // and jQuery 1.2.6, supplied by the client - long story
    $('a').livequery('click', function () {

        alert($.isValidRequest("blah"));
        return false;
    });
});

but it crashes on the alert() with

Microsoft JScript runtime error: Object doesn't support this property or method

This is what worked in the end:

jQuery.isValidRequest = function (options) {

    return true;
}
  • 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-16T04:48:47+00:00Added an answer on May 16, 2026 at 4:48 am

    For a function you intend to call from jQuery instances, you’d define it like this:

    $.fn.MyFunction = function(options)
    {
      // return bool here
    };
    

    And call like any other jQuery method:

    $('selector').MyFunction(...);
    

    A function intended to be called from the global jQuery object (or its $ alias) would be attached directly to that object:

    $.MyFunction = function(options)
    {
      // return bool here
    };
    

    And call the same way:

    $.MyFunction(...);
    

    Note that I’ve used $.fn for brevity – this can cause problems if jQuery is prevented from using the $ alias for compatibility with other libraries. The recommended way to attach a plugin function is:

    (function($) // introduce scope wherein $ is sure to equate to jQuery
    { 
      $.fn.MyFunction = function(options) 
      { 
        // return bool here 
      };
    })(jQuery); // conclude plugin scope
    

    Note also that most jQuery functions return this, to enable chaining; if you opt to return some other value, you’ll be unable to do this. Be sure to document clearly that your function returns a boolean, or you’ll find yourself wondering why e.g. $("...").MyFunction().hide() breaks later on.

    You can read more about extending jQuery here:
    Extending jQuery – plugin development
    and in the jQuery documentation:
    Plugins/Authoring

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

Sidebar

Ask A Question

Stats

  • Questions 488k
  • Answers 488k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If it's an env variable, you should be able to… May 16, 2026 at 8:47 am
  • Editorial Team
    Editorial Team added an answer Yes. In any language it is possible to create a… May 16, 2026 at 8:47 am
  • Editorial Team
    Editorial Team added an answer The STL set does not let you change values it… May 16, 2026 at 8:47 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

How can i create a function which looks like the jquery callback $ Say
How can I create a div dynamically within a function, like this: <div id=mydiv
How can I create a button that will scroll to the next jQuery tab.
I have a jQuery function that allows a user to create a list of
how to create own function and call it another function? like- $('.mycls li').hover(function() {
I'm trying to create a universal function that I can call from multiple places
If youa are serializing a form using something like jQuery, it will often map
I'm using this jQuery Tooltip plugin: http://docs.jquery.com/Plugins/Tooltip I create tooltips for all links when
I have a page with some jQuery, and a separate non-jQuery function. Currently my
I'm using jQuery with the validators plugin. I would like to replace the required

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.