robloach/jquery-once

仅对jQuery元素执行一次操作。

安装: 519

依赖项: 0

建议者: 0

安全: 0

星标: 61

关注者: 8

分支: 20

公开问题: 0

语言:JavaScript

类型:组件


README

Testing NPM downloads

仅对jQuery元素执行一次操作。

过滤掉所有之前已应用相同过滤器的所有元素。它可以用来确保函数只对一个元素应用一次。

安装

用法

有关如何使用jQuery Once的更多信息,请参阅API文档。

// The following will change the color of each paragraph to red, just once
// for the "changecolor" key.
$('p').once('changecolor').css('color', 'red');

// .once() will return a set of elements that yet to have the once ID
// associated with them. You can return to the original collection set by
// using .end().
$('p')
  .once("changecolorblue")
    .css("color", "blue")
  .end()
  .css("color", "red");

// To execute a function on the once set, you can use jQuery's each().
$('div.calendar').once().each(function() {
  // Since there is no once ID provided here, the key will be "once".
});

开发

  1. 确保您正在使用node >= 4node
node --version
  1. 通过npm安装依赖项
npm install
  1. 检查编码风格标准,并执行自动测试
npm test
  1. 使用以下命令构建jquery.once.min.js
npm run build
  1. 更新API文档
npm run docs
  1. 使用语义版本控制标记和发布新版本到npm
git add -A
git commit -m "2.3.0"
git tag 2.3.0
git push origin 2.3.0
npm publish

变更日志

通过访问CHANGELOG.md文件了解变更历史。

许可协议

双重许可协议下

版权所有 © Rob Loach