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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:50:47+00:00 2026-05-24T13:50:47+00:00

In this simplistic example: var myFunction = function(obj) { console.log($(obj)); } I am using

  • 0

In this simplistic example:

var myFunction = function(obj) {
    console.log($(obj));
}

I am using the $. If I use:

jQuery.noConflict();
var myObj = {X:1};
myFunction(myObj);

Then the $ is no longer valid.

But if I wrap myFunction inside of

jQuery(function($) {
var myFunction = function(obj) {
    console.log($(obj));
}
});

Then it’s no longer found. myFunction is in a separate script, so I can’t wrap everything in one gigantic jQuery(function($) {}.

  • 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-24T13:50:48+00:00Added an answer on May 24, 2026 at 1:50 pm

    Try this:

    ( function($) {
      window.myFunction = function(obj) {
        console.log($(obj));
      }
    })(jQuery);
    

    Seperate file:

    myFunction({X:1});
    

    The difference is that your code is executed immediately not after the dom is ready and you are placing the function in the global context (window.) so it will be available everywhere.

    I don’t know what it is your doing, but in this case you may find a JQuery plugin suits you better:

    ( function($) {
      $.fn.myFunction = function(obj) {
        console.log(this);
      }
    })(jQuery);
    

    Seperate file:

    jQuery({X:1}).myFunction();
    

    Of course, $( {X:1} ) might do strange things with JQuery – I’ve never tried it before!

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

Sidebar

Related Questions

Sorry if this is overly simplistic. I've decided that I want to use an
Firstly, I'm starting to use StructureMap, but an example in any DI framework will
I have a method that performs a simplistic 'grep' across files, using an enumerable
I'm sorry if this is a very simplistic question but I'm still learning the
Currently I use the following for checking is a user is logged in: function
This may be very simplistic question but I can't find the answer. I want
I apologize for this overly simplistic question, but I can't seem to figure out
I was trying out the simplistic word count example for hadoop pipes . Unfortunately
In a particular example, I want to extract function calls in a string input
This is a bit of a long shot, but if anyone can figure it

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.