type="search"अपने इनपुट में एक जोड़ें
समर्थन बहुत सुंदर है, लेकिन IE <10 में काम नहीं करेगा
पुराने ब्राउज़रों के लिए क्लैरेबल इनपुट
अगर आपको IE9 सपोर्ट की जरूरत है तो यहां कुछ वर्कअराउंड हैं
एक मानक <input type="text">और कुछ HTML तत्वों का उपयोग करना :
/**
* Clearable text inputs
*/
$(".clearable").each(function() {
var $inp = $(this).find("input:text"),
$cle = $(this).find(".clearable__clear");
$inp.on("input", function(){
$cle.toggle(!!this.value);
});
$cle.on("touchstart click", function(e) {
e.preventDefault();
$inp.val("").trigger("input");
});
});
/* Clearable text inputs */
.clearable{
position: relative;
display: inline-block;
}
.clearable input[type=text]{
padding-right: 24px;
width: 100%;
box-sizing: border-box;
}
.clearable__clear{
display: none;
position: absolute;
right:0; top:0;
padding: 0 8px;
font-style: normal;
font-size: 1.2em;
user-select: none;
cursor: pointer;
}
.clearable input::-ms-clear { /* Remove IE default X */
display: none;
}
<span class="clearable">
<input type="text" name="" value="" placeholder="">
<i class="clearable__clear">×</i>
</span>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
केवल एक का उपयोग करना <input class="clearable" type="text">(कोई अतिरिक्त तत्व नहीं)

एक सेट करें class="clearable"और यह पृष्ठभूमि छवि के साथ खेलें:
/**
* Clearable text inputs
*/
function tog(v){return v?'addClass':'removeClass';}
$(document).on('input', '.clearable', function(){
$(this)[tog(this.value)]('x');
}).on('mousemove', '.x', function( e ){
$(this)[tog(this.offsetWidth-18 < e.clientX-this.getBoundingClientRect().left)]('onX');
}).on('touchstart click', '.onX', function( ev ){
ev.preventDefault();
$(this).removeClass('x onX').val('').change();
});
// $('.clearable').trigger("input");
// Uncomment the line above if you pre-fill values from LS or server
/* Clearable text inputs */
.clearable{
background: #fff url(http://i.stack.imgur.com/mJotv.gif) no-repeat right -10px center;
border: 1px solid #999;
padding: 3px 18px 3px 4px; /* Use the same right padding (18) in jQ! */
border-radius: 3px;
transition: background 0.4s;
}
.clearable.x { background-position: right 5px center; } /* (jQ) Show icon */
.clearable.onX{ cursor: pointer; } /* (jQ) hover cursor style */
.clearable::-ms-clear {display: none; width:0; height:0;} /* Remove IE default X */
<input class="clearable" type="text" name="" value="" placeholder="" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
jsBin डेमो
चाल कुछ सही गद्दी सेट करने के लिए है (मैंने 18px का उपयोग किया) inputऔर पृष्ठभूमि-छवि को दाईं ओर धकेल दिया, दृष्टि से बाहर (मैंने उपयोग किया right -10px center)।
वह 18px पैडिंग आइकन के नीचे पाठ को छिपाने से रोक देगा (जबकि दृश्यमान)।
jQ स्पष्ट आइकन दिखाते हुए वर्ग x(यदि inputमूल्य है) जोड़ देगा ।
अब हमें बस जरूरत है कि jQ के साथ इनपुट्स को क्लास के साथ टारगेट किया जाए xऔर यह पता लगाया mousemoveजाए कि माउस उस 18px "x" एरिया के अंदर है या नहीं; यदि अंदर है, तो कक्षा जोड़ें onX। कक्षा को
क्लिक करने से onXसभी कक्षाएं निकल जाती हैं, इनपुट मान को रीसेट करता है और आइकन को छुपाता है।
7x7px gif: 
Base64 स्ट्रिंग:
data:image/gif;base64,R0lGODlhBwAHAIAAAP///5KSkiH5BAAAAAAALAAAAAAHAAcAAAIMTICmsGrIXnLxuDMLADs=