Git Product home page Git Product logo

irene's Introduction

Irene.js

Irene.js 是啥?

一个瞎寄吧捣鼓的操作Dom元素框架,然后还夹带了私货(👆

有啥用?

很久之前我就有了这样的想法,每当我需要抓取页面的Dom元素进行操作时,不是原生就是JQuery,但是呢,原生啰嗦又麻烦,JQuery多余的功能太多且臃肿,所以就想着做个针对Dom元素操作的框架,进行数据采集或者写些小脚本啥的。

目前处于勉强能用状态。

使用教程?

构造方法

$irene(HTMLElement | String(idName | className | tagName) | Array) -> Irene

// 例子
$irene('p'); // 抓取所有 p 标签
$irene('.madoka'); // 抓取所有类名为 madoka 的标签
$irene('#qwq'); // 抓取 id 为 qwq 的标签

forEach、map、filter、sort、merge、reverse

method: forEach(f) -> void
$irene('p').forEach((item, index) => {
    ...
});

method: map(f) -> Irene
$irene('p').map((item, index) => {
    ...
});

method: filter(f) -> Irene
$irene('p').filter((item, index) => {
    ...
});

method: sort(f=(a,b)=>a-b) -> Irene
$irene('p').sort();

// 合并
method: merge() -> Irene
$irene('p').merge();

method: reverse() -> Irene
$irene('p').reverse();

获取父类Dom

method: parent(filter) -> Irene

// 例子
<div>
    <p></p>
</div>

$irene('p').parent(); // [div]

获取同级Dom

method: siblings(filter) -> Irene

// 例子
<div>
    <h2></h2>
    <p></p>
    <p></p>
</div>

$irene('p').siblings(); // [h2, p, p]

获取子类Dom

method: children(filter) -> Irene

// 例子
<div>
    <h2></h2>
    <p></p>
    <p></p>
</div>

$irene('div').children(); // [h2, p, p]

在当前头部添加元素、在当前尾部添加元素

method: begin(elem) -> Irene
method: append(elem) -> Irene

在子类头部添加元素、在子类尾部添加元素

method: beginChild(elem) -> Irene
method: appendChild(elem) -> Irene

删除与渲染

method: remove() -> Irene
method: render() -> Irene

at、range、first、last

method: at(index) -> Irene
method: range(startIndex, endIndex) -> Irene
method: first() -> Irene
method: last() -> Irene

text、setText

method: text() -> String
method: setText() -> Irene

clone、clear、getElem、getElems、len、getLink

method: clone(isDeep = true) -> Irene
method: clear() -> void
method: getElem() -> Item
method: getElems() -> Array
method: len() -> Number
method: getLink() -> Irene

irene's People

Contributors

ayawen01 avatar ltorch avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.