jQuery Plugin to Clear Input Field - clearsearch

File Size: 3.73KB
Views Total: 3656
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
jQuery Plugin to Clear Input Field - clearsearch

clearsearch is a simple and fast jQuery plugin that adds a close button within the input field to allow to quickly clear the value your user input.

How to use it:

1. Include jQuery library and clearsearch.js on your web page

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="src/jquery.clearsearch.js"></script>

2. Markup

<input class="clearable" type="text" placeholder="search" />

3. Initialize plugin (with callback)

<script>
$(function() {
    $('.clearable').clearSearch({ callback: function() { console.log("cleared"); } } );

    // update value
    $('.clearable').val('sample value').change();
    
    // change width
    $('.clearable').width('200px').change();
});
</script>

This awesome jQuery plugin is developed by waslos. For more Advanced Usages, please check the demo page or visit the official website.