noob
noob

Reputation: 4777

how to change font style of text in textbox on click?

how can i do this using javascript?

my textbox has a default value which is italic but when it is clicked the textbox will be cleared and the fontstyle should be normal.

Upvotes: 3

Views: 30698

Answers (3)

Antonio
Antonio

Reputation: 21

document.getElementById(inputId).style.fontStyle="normal";

Upvotes: 2

Canavar
Canavar

Reputation: 48088

try something like that :

<input type="text" value="Enter user ID here" 
  style="font-style:italic;" 
  onfocus="this.value='';this.style.fontStyle='normal';" 
  onblur="clickrecall(this,'Enter user ID here');this.style.fontStyle='italic';">

EDIT : As we clear the format when user enters the textbox, we should set the fontStyle to italic back when he goes out.

Upvotes: 4

techzen
techzen

Reputation: 2955

set the style in javascript method:

document.getElementById('test').style="font-style:normal;"

Upvotes: 1

Related Questions