Home > Web Front-end > JS Tutorial > A lightweight javascript library pj introduction_lib_js

A lightweight javascript library pj introduction_lib_js

WBOY
Release: 2016-05-16 18:13:43
Original
1709 people have browsed it

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("

");//Generate a div
pj("
Content
");//Generate a div with content
static Properties and methods
LEFT_POSITION
RIGHT_POSITION
TOP_POSITION
BOTTOM_POSITION
LEFT_TOP_POSITION
LEFT_BOTTOM_POSITION
RIGHT_TOP_POSITION
RIGHT_BOTTOM_POSITION
ready(fn);
extend (target,fn);
bind({method:function(){}})
isObject(elem)
isFunction(elem)
isArray(elem)
isString(elem)
trim(str)
merge(target,src)
getStyle(target,name)
setStyle(target,{})
mouseX(e)
mouseY(e)
stopBubble(e)
stopDefault(e)
pageHeight()
pageWidth()
windowHeight()
windowWidth()
setOpacity(target,value)
enableDrag( trigger,target)
parseToQueryString(form)
isContain(parent,child)
id(id)
tag(tag)
resetCSS(target,{})
x(target )
y(target)
wh(target,name)
pj object properties and methods
timer
length
get()
each()
addListener( )
attr()
removeAttr()
stop()
appendTo()
remove()
addClass()
removeClass()
setClass()
cut()
step()
setLocationRelatedTo()
isVisible()
locate()
bind()
getStyle()
setStyle()
abort()
blur()
change()
click()
dblclick()
error()
focus()
keydown()
keypress( )
keyup()
load()
unload()
mousedown()
mousemove()
mouseout()
mouseover()
mouseup()
reset()
resize()
select()
submit()
left()
top()
right()
bottom()
height()
width()
animate()
slideDown()
slideUp()
slideRight()
slideLeft()
scrollDown()
scrollUp( )
scrollRight()
scrollLeft()
hide()
show()
fadeIn()
fadeOut()
Small demo

Copy code The code is as follows:





无标题文档











打包下载地址 http://www.jb51.net/jiaoben/33561.html
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template