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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:47:38+00:00 2026-05-27T15:47:38+00:00

Ok, I have been having a VERY hard time figuring this out. I guess

  • 0

Ok, I have been having a VERY hard time figuring this out. I guess I’m still new when it comes to creating jQuery plugins. I am going to post the entire code in a JSFiddle but here is the jist of the problem. My plugin right now uses the $.fn.extend method to allow users to chose a selector like: $(document).BGP({/*options*/}); —this is fine except the BGP function will ONLY work with the “document” therefore I would like to remove the selector option and program this into the plugin. So that the user can call like: $.BGP({/options/});

I am lost on how to do this!!! I have tried many different things and nothing works.

(function ($) {
    $.fn.extend({
            BGP: function (options) {
                    //Set the default
                    var defaults = {
                            backgroundStretch: "",
                            backImage: "",
                            midImage: "",
                            foreImage: ""...and much more

Here is the JS fiddle—-this is a working example with the “document” selector.

Also I have some minified code at the top of the JS….you can ignore that. My code starts about halfway down.

My call for the function is at the bottom of the JS.

http://jsfiddle.net/mgunnels/3Z2sK/6/

  • 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-27T15:47:39+00:00Added an answer on May 27, 2026 at 3:47 pm

    To create a “static” plugin, all you need to do is assign your function directly to the jQuery object:

    (function($) {
        $.BGP = function(arg1) { ... };
    })(jQuery);
    

    Usage:

    $.BGP("foo");
    

    Updated example: http://jsfiddle.net/n8ea4/

    Additionally, you don’t need the .each loop at all since there can only be one document.

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

Sidebar

Related Questions

I am still new at PHP/Javascript/Ajax and am having a very hard time (been
I have been having a lot of trouble figuring out how I can access
I have been having a very difficult time editing my .htaccess file to do
I know it has been asked several times but I'm having very hard time
We have been having some debate this week at my company as to how
I have been having problems with creating a download list of files for a
I have been having this issue in iterating through an array of keys and
Hello I have been having trouble with this for a while now. I have
This is a really weird problem that I have been having. When I download
Platform: ASP.NET 3.5, ASP.NET Ajax intermixed I'm very green to jQuery, so have been

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.