0

I have an existing jquery collection, generated like this:

obj = $('some-selector')

obj is passed to a method that uses $('some-other-selector').data('some-data-attribute');

However, the value of $ may have been redefined by the time this method is called (say, because of different jquery versions on the page).

Therefore, I need to get hold of the $ object that was used to generate the original obj. Is there some way I can go from obj to the $ object?

user1001630
  • 493
  • 1
  • 3
  • 16
  • 1
    I'm not sure what you meant.. but in case you need to get the jQuery element from a regular HTMLElement you could use `$(object)` – Diego D Sep 01 '22 at 08:03

1 Answers1

1

Can't you just store the original jQuery object in a variable to use it later or whenever you need to? Anyway, for this kind of scenarios, you should rather use the specific jQuery tool, noconflict.

See: Can I use multiple versions of jQuery on the same page?

bitfella
  • 314
  • 1
  • 14
  • yes, i can but I have a lot of these functions, and don't want to pass $ to each of them. I am already passing obj though. – user1001630 Sep 01 '22 at 10:42