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 496k
  • Answers 496k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer When a negative index is specified for eq, it starts… May 16, 2026 at 11:32 am
  • Editorial Team
    Editorial Team added an answer Since you mention C#, I'm going to assume you mean… May 16, 2026 at 11:32 am
  • Editorial Team
    Editorial Team added an answer Thanks to a comment from @Sorin, the official documentation is… May 16, 2026 at 11:32 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 div dynamically within a function, like this: <div id=mydiv
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
I have created webpage and I am calling it from Jquery function. Technically I
I'd to create some transitions between pages. I've made it this way: $(div.fading).css('display', 'none');
So, I use jQuery quite extensively and I am well aware of the right
Summary Can you explain the reasoning behind the syntax for encapsulated anonymous functions in
I have an HTML page. I have created a frame using background repeat function.
I am new to jQuery and I am having trouble with the syntax, selectors
I am trying to understand why ZendX_JQuery will not work when used directly in

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.