npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

zebra_clearinput

v2.0.0

Published

A tiny jQuery plugin for enhancing web forms by allowing users to easily clear values in text input boxes

Readme

Zebra ClearInput  Tweet

A tiny, high-performance jQuery plugin for enhancing web forms by allowing users to easily clear input field values

npm Total Monthly License

Zebra ClearInput is a lightweight, optimized jQuery plugin that enhances form usability by adding an intuitive clear button to input fields. When users click this button, it instantly erases the input content and returns focus to the field for immediate re-entry.

The clear button appears automatically when users start typing and intelligently manages its visibility: it shows immediately on focus or hover, and gracefully hides when the field is empty or loses focus.

Features

  • works out of the box with sensible defaults and minimal configuration
  • optimized performance with event delegation
  • supports multiple independent instances with isolated namespacing
  • dynamically handles inputs added after initialization via update() method
  • responsive layout preservation
  • graceful error handling and memory leak prevention
  • destroy() method for complete cleanup
  • really tiny - weighs ~2KB uncompressed and ~800 bytes gzipped
  • works in all modern browsers - 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! 🎉

Donate

Demo

See the demos

Requirements

Zebra ClearInput has no dependencies other than jQuery 1.7.0+

Installation

Zebra ClearInput is available as a npm package. To install it use:

# 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:

<script src="https://code.jquery.com/jquery-3.5.0.min.js"></script>
<script>window.jQuery || document.write('<script src="path/to/jquery-3.5.0.js"><\/script>')</script>

Load the Zebra ClearInput jQuery plugin:

<script src="path/to/zebra_clearinput.min.js"></script>

Alternatively, you can load Zebra ClerInput from JSDelivr CDN like this:

<!-- for the most recent version, not recommended in production -->
<script
  src="https://cdn.jsdelivr.net/npm/zebra_clearinput@latest/dist/zebra_clearinput.min.js"></script>

<!-- for a specific version -->
<script
  src="https://cdn.jsdelivr.net/npm/[email protected]/dist/zebra_clearinput.min.js"></script>

<!-- replacing "min" with "src" will serve you the non-compressed version -->

Load the style sheet file from a local source

<link rel="stylesheet" href="path/to/zebra_clearinput.min.css">

...or from JSDelivr CDN

<!-- for the most recent version -->
<link
  rel="stylesheet"
  href="https://cdn.jsdelivr.net/npm/zebra_clearinput@latest/dist/zebra_clearinput.min.css">

<!-- for a specific version -->
<link
  rel="stylesheet"
  href="https://cdn.jsdelivr.net/npm/[email protected]/dist/zebra_clearinput.min.css">

<!-- replacing "min" with "src" will serve you the non-compressed version -->

Now, within the DOM-ready event do

$(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

Methods

destroy()

Removes a previously created instance of the plugin. This method cleans up all event handlers, removes buttons, unwraps containers and clears data attributes.

// apply to all text input elements
var clearInput = new $.Zebra_ClearInput('input[type="text"]');

// remove plugin
clearInput.destroy();

update()

Updates the plugin to initialize clear input buttons on dynamically added inputs. This method scans the original selector for any new input elements that weren't present during initial plugin initialization and adds clear buttons to them.

// apply to all text input elements
var clearInput = new $.Zebra_ClearInput('input[type="text"]');

// add new inputs dynamically
$('body').append('<input type="text" name="dynamic">');

// update to initialize the new inputs
clearInput.update();

Sponsors

Cross browser/device testing is done with

BrowserStack