开发者

how to format the hint displayed inside a html form field?

There was a question previously on how to show hints in a text field (html form field), which clears automatically when the user clicks on the field under consideration. As in, when the field gets focus, the hint displayed inside the form gets cleared without the user having to开发者_开发问答 manually delete the characters.

The solution given (and it works perfectly) -

<input onfocus="if (this.value=='search') this.value = ''" type="text" value="search">

Now my question is, how do you format the text that is displayed as the hint (in this case "search"). By formatting, i would want it to be in a certain color and font type.

I can do this to the other fields, which do not have this preloaded hint in it, by using css- color:#123123; font-family:calibri;

Thanks!


You're asking about styling the content (value) of an input element.

You can use regular CSS for this:

input {
  color:#123123;
  font-family:Calibri;
}

Working example: http://jsfiddle.net/fxxp4/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜