How to change the font style of text in a text box when clicked?

how can i do this using javascript?

My text field has a default value, which is italicized, but when I click on it, the text field will be cleared and the font style should be normal.

+3
source share
3 answers

try something like this:

<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: . When we clear the format when the user enters a text field, we must set the fontStyle to italics when it turns off.

+4
source
document.getElementById(inputId).style.fontStyle="normal";
+2
source

javascript:

document.getElementById( '') = " : ;".

+1

Source: https://habr.com/ru/post/1716974/


All Articles