Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stefangabos/zebra_clearinput
A tiny jQuery plugin for enhancing web forms by allowing users to easily clear values in text input boxes
https://github.com/stefangabos/zebra_clearinput
forms input javascript jquery jquery-plugin text-input usability user-experience
Last synced: 17 days ago
JSON representation
A tiny jQuery plugin for enhancing web forms by allowing users to easily clear values in text input boxes
- Host: GitHub
- URL: https://github.com/stefangabos/zebra_clearinput
- Owner: stefangabos
- License: lgpl-3.0
- Created: 2023-09-16T13:23:09.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-10-25T10:41:16.000Z (22 days ago)
- Last Synced: 2024-10-25T11:31:44.697Z (22 days ago)
- Topics: forms, input, javascript, jquery, jquery-plugin, text-input, usability, user-experience
- Language: JavaScript
- Homepage: https://stefangabos.github.io/Zebra_ClearInput/
- Size: 303 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Zebra ClearInput [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=A+tiny+jQuery+plugin+for+enhancing+web+forms+by+allowing+users+to+easily+clear+values+in+text+input+boxes&url=https://github.com/stefangabos/Zebra_ClearInput&via=stefangabos&hashtags=jquery,javascript)
*A tiny jQuery plugin for enhancing web forms by allowing users to easily clear values in text input boxes*
[![npm](https://img.shields.io/npm/v/zebra_clearinput.svg)](https://www.npmjs.com/package/zebra_clearinput) [![Total](https://img.shields.io/npm/dt/zebra_clearinput.svg)](https://www.npmjs.com/package/zebra_clearinput) [![Monthly](https://img.shields.io/npm/dm/zebra_clearinput.svg)](https://www.npmjs.com/package/zebra_clearinput) [![](https://data.jsdelivr.com/v1/package/npm/zebra_clearinput/badge?style=rounded)](https://www.jsdelivr.com/package/npm/zebra_clearinput) [![License](https://img.shields.io/npm/l/zebra_clearinput.svg)](https://github.com/stefangabos/Zebra_ClearInput/blob/master/LICENSE.md)
Zebra ClearInput is a lightweight jQuery plugin designed to enhance the usability of web forms by adding a user-friendly feature that allows users to effortlessly clear the content of input fields. This is achieved by attaching a small icon to input fields. When users click on this icon, it promptly erases any text that has been entered.
As soon as a user begins typing in the input field, the option to clear the input value becomes visible. Once the input field loses focus, the option to clear the value reappears when the mouse hovers over the input field.
## Features
- it works out of the box and has (almost) no configuration options
- it is really tiny - it weighs 1.4KB uncompressed and ~600 bytes gzipped
- works in any modern browser - Firefox, Chrome, Safari, Edge, Opera## 🎂 Support the development of this project
Your support means a lot and it keeps me motivated to keep working on open source projects.
If you like this project please ⭐ it by clicking on the star button at the top of the page.
If you are feeling generous, you can buy me a coffee by donating through PayPal, or you can become a sponsor.
Either way - **Thank you!** 🎉[](https://github.com/stefangabos/Zebra_ClearInput) [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LLXP492Y7VYZJ) [](https://github.com/sponsors/stefangabos)
## Demo
See the [demos](https://stefangabos.github.io/Zebra_ClearInput/)
## Requirements
Zebra ClearInput has no dependencies other than jQuery 1.7.0+
## Installation
Zebra ClearInput is available as a [npm package](https://www.npmjs.com/package/zebra_clearinput). To install it use:
```bash
# the "--save" argument adds the plugin as a dependency in packages.json
npm install zebra_clearinput --save
```## How to use
First, load jQuery from a CDN and provide a fallback to a local source like:
```html
window.jQuery || document.write('<script src="path/to/jquery-3.5.0.js"><\/script>')
```Load the Zebra ClearInput jQuery plugin:
```html
```
Alternatively, you can load Zebra ClerInput from [JSDelivr CDN](https://www.jsdelivr.com/package/npm/zebra_clearinput) like this:
```html
```
Load the style sheet file from a local source
```html
```
...or from [JSDelivr CDN](https://www.jsdelivr.com/package/npm/zebra_clearinput)
```html
```
Now, within the DOM-ready event do
```javascript
$(document).ready(function() {// apply to all text input elements
new $.Zebra_ClearInput('input[type=text]');// apply to certain text input elements
new $.Zebra_ClearInput('input.myClass');// apply to all text input elements and
// add the default CSS class name for the buttons and a custom one
new $.Zebra_ClearInput('input[type="text"]', {
button_class_name: 'Zebra_ClearInput myCustomStyles'
});});
```## Configuration options
## Properties
Property
Type
Default
Description
container_class_name
string
Zebra_ClearInput_Container
The CSS class(es) to be applied to the container DIV that will wrap the target text input element
button_class_name
string
Zebra_ClearInput
The CSS class(es) to be applied to the button associated with the text input element
## Methods
### `destroy()`
Removes a previously created instance of the plugin.
```javascript
// apply to all text input elements
var clearInput = new $.Zebra_ClearInput('input[type="text"]');// remove plugin
clearInput.destroy();
```## Sponsors
Cross browser/device testing is done with
[![BrowserStack](https://github.com/stefangabos/Zebra_Dialog/raw/master/examples/browserstack.png)](https://www.browserstack.com/)