Pre Exam Test Practice (SSC | Banking | IAS | GATE | State Level | CLAT | Railways | Insurance | Teaching Exams | NDA | Defence | IES |State Exam )

Organizational Research By

Surprising Reserch Topic

clear icon inside input text

clear icon inside input text  using -'javascript,jquery,html,css'

I'm wondering if there is a quick way to create an input text element with an icon on the right to clear the input element itself (like the google search box).

I looked around but I only found how to put an icon as background of the input element.

Is there a jQuery plugin or something else?


EDIT: I want the icon inside the input text element

something like:

|                                               X|


asked Sep 21, 2015 by shegokar.anjeet
0 votes

Related Hot Questions

Government Jobs Opening

​ Example:

answered Sep 21, 2015 by mannumits1
0 votes

EDIT: I found this link. Hope it helps.

You have mentioned you want it on the right of the input text. So, the best way would be to create an image next to the input box. If you are looking something inside the box, you can use background image but you may not be able to write a script to clear the box.

So, insert and image and write a JavaScript code to clear the textbox.

answered Sep 21, 2015 by jekbishnoi
0 votes

Here's a jQuery plugin (and a demo at the end).

I did it mostly to illustrate an example (and a personal challenge). Although upvotes are welcome, the other answers are well handed out on time and deserve their due recognition.

Still, in my opinion, it is over-engineered bloat (unless it makes part of a UI library).

answered Sep 21, 2015 by mannumits1
0 votes

If you want it like Google, then you should know that the "X" isn't actually inside the -- they're next to each other with the outer container styled to appear like the text box.




.x-input {
    border: 1px solid #ccc;

.x-input input.x-input-text {
    border: 0;
    outline: 0;


answered Sep 21, 2015 by android_master
0 votes

Using a jquery plugin I have adapted it to my needs adding customized options and creating a new plugin. You can find it here:

An example of a simple usage:

" rel="nofollow" target="_blank">'>
" rel="nofollow" target="_blank">'>

" rel="nofollow" target="_blank">">

Not empty

Obtaining something like this:

enter image description here

answered Sep 21, 2015 by sandeep bhadauria
0 votes

jQuery Mobile now has this built in:

Jquery Mobile API TextInput docs

answered Sep 21, 2015 by thiru
0 votes

No need to include CSS or image files. No need to include that whole heavy-artillery jQuery UI library. I wrote a lightweight jQuery plugin that does the magic for you. All you need is jQuery and the plugin. =)

jQuery InputSearch sneak peek

Fiddle here: jQuery InputSearch demo.

answered Sep 21, 2015 by 20shahi