我有以下代码:
<input id="firstName" name="fname" type="text" maxlength="50" placeholder="First Name *" required>
如何在占位符值红色中给(*)符号上色而不用其上的其他文本(即名文本)上色?
任何帮助深表感谢!
谢谢!铝
不幸的是,无法更改输入中某些文本的颜色:(您可以尝试使用contenteditable
div:
<div class="input" contenteditable>First Name <span style="color:red;">*</span></div>
然后,您必须使用JS添加和删除占位符:
$(function(){
$('.input').focus(function(){
$(this).html('');
});
$('.input').blur(function(){
if($(this).html()=='') this.innerHTML='First Name <span style="color:red;">*</span>';
});
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句