Giter Club home page Giter Club logo

jquery-once's Introduction

jQuery Once NPM version

Build Status NPM downloads Dependency Status Coverage Status

Act on jQuery elements only once.

Filters out all elements that had the same filter applied on them before. It can be used to ensure that a function is only applied once to an element.

Install

Method Installation
npm npm install jquery-once --save
Composer composer require robloach/jquery-once
Bower bower install jquery-once
Component component install RobLoach/jquery-once
jsDelivr //cdn.jsdelivr.net/jquery.once/2.1.1/jquery.once.min.js
cdnjs //cdnjs.cloudflare.com/ajax/libs/jquery-once/2.1.1/jquery.once.js

Usage

See the API documentation for more information on how to use jQuery Once.

// 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".
});

Development

  1. Ensure you are using node >= 4:
node --version
  1. Install dependencies through npm:
npm install
  1. Check coding style standard, and automated testing:
npm test
  1. Build jquery.once.min.js with:
npm run build
  1. Update API documentation:
npm run docs
  1. Tag and publish the new versions to npm with Semantic Versioning:
git add -A
git commit -m "2.1.2"
git tag 2.1.2
git push origin 2.1.2
npm publish

Docker

It is possible to run tests through Docker Compose:

docker-compose up

Change Log

Discover the change history by heading on over to the CHANGELOG.md file.

License

Dual licensed under:

Copyright © Rob Loach

jquery-once's People

Contributors

johnalbin avatar olavorn avatar robloach avatar theodoreb avatar

Watchers

 avatar  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.