ktty1220 / jquery.temp-class

Add class only for a certain time and remove class when the certain time passes.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jQuery Temp Class

Add class only for a certain time and remove class when the certain time passes.

Usage

Load jQuery and jQuery Temp Class.

<script src="/path/to/jquery.js"></script>
<script src="/path/to/jquery.temp-class.js"></script>

Call $(element).tempClass().

// Add 'error' class to $('#foo'),
// and remove 'error' class from $('#foo') after 3000ms passed,
// and then output console.log('done').
$('#foo').tempClass('error', 3000, function () {
  console.log('done');
});

// Add 'error' class to $('#foo'),
// and remove 'error' class from $('#foo') after 3000ms passed.
$('#foo').tempClass('error', 3000);

// Add 'error' class to $('#foo'),
// and remove 'error' class from $('#foo') after 1000ms(default) passed.
$('#foo').tempClass('error');

License

MIT

© 2017 ktty1220

About

Add class only for a certain time and remove class when the certain time passes.


Languages

Language:HTML 63.0%Language:JavaScript 37.0%