jQuery currently uses window
as its default element so any call like $('div')
will look for div
tags inside window
.
Is there any way to change defaults on jQuery like:
$.defaultRoot = $('.anyOtherRootElement');
$('div').text("Hello");
this will select any div inside the elements containing .anyOtherRootElement
class.
Thanks in advance
Upate
just an update refining the question a bit more here:
I would like to perform the actions above based on external queries coming from external script which won't know what defaultRoot
is so they can still be calling what is supposed to be the current base, so in this instance, I'm afraid adding the a second parameter wouldn't be an option, unfortunately.
And at the same time creating a function
which returns defaultRoot.find(el)
would prevent me of using first-level methods such $.trim
, $.each
, etc… so unfortunately that would not be possible as well.