Compared with other languages, the JavaScript scripting language is too small and exquisite, lively and smart. I personally like writing javascript code very much. Although the Internet is full of famous javascript libraries, jQuery, Prototype, Base, ExtJs..., they are also very powerful and easy to use. But one thing that is not very satisfactory is that the library itself is too large. Sometimes just to use a few of the functions, the entire library must be imported. In the case of jQuery, it is still more than 70 KB after compression, which is sometimes larger than a web page file. But we need a library to assist in development, so we wrote a lightweight javascript library that only supports some simple selectors. Many of the selectors borrowed methods from jQuery and named them pj. Download the source code
Here is a brief introduction to the
selector:
pj("#id");//id selector, such as: pj("#header"), taking the id as header Element
pj("tag");//tag selector, such as: pj("div"), get all divs on the page
pj("[tag].class");//class selector , such as: pj("[tag].ClassName"), get the [tag] element whose class is ClassName
pj("#id>tag"); //Get all specified elements under the specified id; such as: pj ("#header>a"), take the id as all a elements under the header element [including descendant elements]
pj("tag>tag");//Get all the elements of the specified tag under the specified tag; such as: pj("li>a") Get the a element under all li elements on the page [including descendant elements]
pj("tag[,#id,tag.class][attr=value]:0,2"); //Get elements based on the specified attribute or subscript; for example: pj("div[name=value]:0,3") Get the first and fourth elements in the page that contain the name attribute and have the value
pj("