npm.io
1.0.1 • Published 8 years ago

tinyjquery

Licence
MIT
Version
1.0.1
Deps
0
Size
767 kB
Vulns
0
Weekly
0

Description

A Web Front Library imitated from jQuery, based on ecmascript 2015, supported IE9 and above.

Use

  • insert into head tag
<script src='//raw.githubusercontent.com/bougieL/tinyJquery/master/dist/js/tinyJquery.min.js'></script>

or

  • import in commonJs
npm i tinyjquery -S
import $ from 'tinyjquery'

Characteristics

  1. Batch operation Change all divisions' background color:
    $('div').css({background: 'green'})
  2. Chain operation Execute another operation directly after an operation:
    $('div').css({background: 'green'}).ac('green-box')
  3. Callback ajax supported IE9 and above
    $.ajax({
        url: '/api/myUrl',
        method: 'get',
        success: function(data) {
            console.log(data)
        },
        error: function(err) {
            console.error(err)
        }
    })

Method

Use $('cssSelector') or $(nativeDomObject) or $(nativeDomObjectArray) or $(arrayLikeObject) to generate a TinyJquery obejct.
For example: $('div'), $('.box'), $('#target'), $(document.getElementById('#target')), $(document.getElementsByClassName('box')), $(document.querySelectorAll('.box'))...

Method Arguments Jquery
on eventName, fn, [ bubble = false ] bind
un eventName, fn, [ bubble = false ] unbind
ac className addClass
rc className removeClass
tc className toggleClass
cc className hasClass
css styleObj css
val [ value ] val
html [ html ] html
attr attribute, [ attributeValue ] attr
parent ------ parent
eq index eq
find cssSelector find
getDom ------ get(0)
getDomList ------ ------
each callback each
append nativeDom || TinyJquery append
appendTo nativeDom || TinyJquery appendTo
remove ------ remove
height ------ height
width ------ width
bound ------ offset

Keywords