Is there a way to replace $ with something like $_sub whose actions are contained within a div? For example, I want to inject $_sub to a function and instead of using $, the function uses $_sub to limit its scope within the div while preserving the methods that can be called on $ (e.g I should be able to do $_sub.ajax())
<a href="#">Outside </a>
<div id="contents" >
<a href="#">Inside </a>
</div>
function modify($_sub) {
var inner_a = $_sub("a"); //should return only the inner <a>
}
context will not work for me in this scenario. I want the function to think $_sub is just like $. I can change the function signature to rename $_sub to $ so that the function doesn't even know that it is using a scope limited version of actual $.