Adam
Adam

Reputation: 20882

CSS + putting text into a input type=text

I have the following code and it works fine in all browsers:

 <input type="text" id="fileUploadTextBox" value="Browse My Computer"/>

When it comes to IE I wanted to change the text slightly to

 <input type="text" id="fileUploadTextBox" value="Browse My Computer (Double Click)"/>

Can I do this using CSS? I know how to run a separate CSS file for IE.

Or is there another way to do this?

thx

Upvotes: 0

Views: 97

Answers (2)

Ahsan Khurshid
Ahsan Khurshid

Reputation: 9469

By using conditional comments you can do this:

For Other Browsers:

<!--[if !IE]><!-->
    <input type="text" id="fileUploadTextBox" value="Browse My Computer"/>
<!--<![endif]-->

For IE Browsers:

<!--[if IE]>
    <input type="text" id="fileUploadTextBox" value="Browse My Computer (Double Click)"/>
<![endif]-->

SEE DEMO

Or you can use Javascript/jQuery to achieve it.

Upvotes: 4

Dane Balia
Dane Balia

Reputation: 5367

This Javascript with jQuery should work:

if ( $.browser.msie ) {
  <input type="text" id="fileUploadTextBox" value="Browse My Computer (Double Click)"/>
} else {
  <input type="text" id="fileUploadTextBox" value="Browse My Computer"/>
}

Upvotes: -1

Related Questions