值/占位符 - 字词的不同样式 [英] Value/Placeholder - different styling for words

查看:105
本文介绍了值/占位符 - 字词的不同样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到占位符问题。
我想问的是,是否有可能在输入字段中设置值的样式,但是对该值的字样进行不同的设置。

I'm having problem with placeholders. I want to ask, is there possibility to style value in input fields but in the way to style words of that value different.

例如,如果我们具有初始值First Name的输入字段我想有绿色 > (这只是一个例子)的第一个 )。

For example, if we have input field which have initial value "First Name" i want to have green color for "First", and red color for "Name" (this is just an example).

我最近遇到了这个问题,但我避免了这一点,并用一种​​风格风格。
现在,我在另一个项目上工作,也有同样的问题。

I met this problem recently but i avoid this and style it with one style. But now, im working on another project and there is the same problem.

我想知道这是否可能?

注意:我使用值作为占位符(而不是占位符html属性),因为

Note: Im using value as "placeholder" (instead of placeholder html attribute) because of ie.

<input type="text" value="First Name" onFocus="if (this.value == 'First Name') {this.value = '';}" onBlur="if (this.value == '') {this.value = 'First Name';}" />

Tnx

推荐答案

不幸的是它不可能。当涉及到样式的表单元素,有很多障碍,颜色可以设置为一个元素不是chracters,请尝试这:

unfortunately its not possible. when it comes to styling the form elements, there are many hindrances, color can be set to for an element not chracters, try this:

http://jsfiddle.net/Fgd2e/1/

这篇关于值/占位符 - 字词的不同样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆