Hello guys I want to have something like JQuery selectors. What I mean is this:
JQuery has a selector something like this:
$("#exampleID").JQexampleMethod();
I want to have something similar for my class. for example
selector("#exampleID").MYexampleMethod();
but I can’t find out how to do this. I know how to create class and define them. But can’t achieve my needs. So far what I have done is this:
var class = new TestClass();
class.selector("#exampleID").MyExampleMethod();
It’s not that easy to replicate jQuery because it contains of all kinds of fixes for cross-browser issues and even a whole selector library.
That said, if you disregard those issues, a simple prototype can be as follows:
You could use it as follows: