Clus —— 压缩后仅 8k 的 jQuery-like 库

1,042 阅读1分钟

dependencies devDependencies

Commit Type Emoji
Initial Commit 🎉 :tada:
Structure 🎨 :art:
Documentation 📝 :memo:
New Idea 💡 :bulb:
New Feature :sparkles:
Bug 🐛 :bug:
Version Tag 🔖 :bookmark:
Performance 🐎 :racehorse:
Tooling 🔧 :wrench:
Tests 🚨 :rotating_light:
Deprecation 💩 :poop:
Work In Progress (WIP) 🚧 :construction:
Upgrading ⬆️ :arrow_up:

Example:

"🎨 fixing coding standard"

$ npm i clus --save
# or
$ bower i clus

$(document).ready(function () {
    // DOM is ready
});

// or

$(function () {
    // DOM is ready
});

Example:

$('.hello').addClass('world');
$('p').addClass('hello world');
// or
$('p').addClass('hello').addClass('world');

Example:

$('.hello').removeClass('hello').addClass('hi');
$('p').addClass('hello world').removeClass('hello world');
// or
$('p').addClass('hello world').removeClass('hello').removeClass('world');

Example:

$('p').hasClass('hello'); // true
$('p').hasClass('world'); // false

Example:

$('p').toggleClass('hello');

Example:

$('body').append('

Hello Clus

');

Example:

$('

Hello Clus

').appendTo('body');

Example:

$('.hello').parent();

Example:

$('.hello').parents();
$('.hello').parents('body');

Example:

$.each(['just', 'hello', 'world'], function (item, index) {
    console.log(item, index);
});
// just 0
// hello 1
// world 2

Example:

$('.hello').each(function (item, index) {
    $(this).addClass('world');
    console.log($(this));
});

Example:

$.map(['just', 'hello', 'world'], function (item, index) {
    console.log(item, index);
});
// just 0
// hello 1
// world 2

Example:

$('.hello').map(function (item, index) {
    $(this).addClass('world');
    console.log($(this));
});

Example:

$('.hello').on('click', function () {
    console.log($(this));
});

$(document).on('click', '.hello', function () {
    console.log($(this));
});

Example:

let hello = function () {
    console.log('hello');
}
$(document).on('click', '.hello', hello);
$(document).off('click', '.hello', hello);