Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put an icon inside textbox in jquery mobile [closed]

I want to put an icon inside textbox (should be at right end of the textbox, like clearText icon in search input type) in jquery mobile. I have overridden some css classes of jquery mobile, still I couldn't achieve. Can someone please provide the solution?

like image 365
Sriks Avatar asked Feb 12 '13 18:02

Sriks


People also ask

How do I add an icon to my input box?

To add icon inside the input element the <i> tag and <span> tag are used widely to add icons on the webpages. To add any icons on the webpages or in some specific area, it needs the fontawesome link inside the head tag. The fontawesome icon can be placed by using the fa prefix before the icon's name.


1 Answers

One simple solution is to put your text box and image into a div that is relatively positioned. Then you set the image position to absolute and give it the needed right value.

HTML:

<div>
    <input type="text" />
    <img src="http://the-dream.co.uk/images/lens_icon.png" width="15" />
</div>

CSS:

div {
    position:relative;
    width:200px
}

input{
    width:200px;
}

img{
    position:absolute;
    right:5px;
    top:5px;
}

Check that fiddle for a demo:

http://jsfiddle.net/8sbpn/1/

like image 137
deadlock Avatar answered Oct 29 '22 20:10

deadlock