可能的重复:
如何使用 Javascript 或 JQuery 在 HTML 中突出显示输入文本字段的一部分 https://stackoverflow.com/questions/10341843/how-to-highlight-a-part-part-of-an-input-text-field-in-html-using-javascript-or
有谁知道如何突出显示某些文本input[type=text]
or textarea
?
是否可以?
你必须放置一个div
在你的后面textarea
然后根据文本设置样式。
Notes:
- 设置你的
textarea
background-color
透明地看到你的highlighter
color.
- Your
highlighter
必须与您的样式和文本内容相同textarea
把span
在正确的地方。
- 设置你的
highlighter
文本颜色与背景颜色相同,否则您会看到<b>
效果相同,对于span
.
html:
<div class="highlighter">some text <span>highlighted</span> some text</div>
<textarea>some text highlighted some text</textarea>
css:
.highlighter, textarea {
width: 400px;
height: 300px;
font-size: 10pt;
font-family: 'verdana';
}
.highlighter {
position: absolute;
padding: 1px;
margin-left: 1px;
color: white;
}
.highlighter span {
background: red;
color: red;
}
textarea {
position: relative;
background-color: transparent;
}
demo http://jsfiddle.net/ricardolohmann/9Y99F/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)