[英]Change a single placeholder character color?
Is there anyway to get this script to work if its even possible, I want to add a red (*) to the end of specific placeholders I tried the CSS :after pseudo which works really well in chrome. 无论如何,是否有可能使该脚本正常运行,我想在尝试使用CSS的特定占位符的末尾添加一个红色(*):after伪,在chrome中效果很好。 But I need it cross browser. 但是我需要跨浏览器。
I have some java script that replaces any ( ) with a red( ) but with it being in a place holder it displays the tags. 我有一些用红色( )替换任何( )的 Java脚本,但是在占位符中显示了标签。
<head>
#inputFormBorder ::-webkit-input-placeholder:after {color:red;content:"*";}
#inputFormBorder ::-moz-placeholder:after {color:red;content:"*";}
#inputFormBorder :-ms-input-placeholder:after {color:red;content:"*";}
#inputFormBorder0 ::-webkit-input-placeholder:after {content:"";}
#inputFormBorder0 ::-moz-placeholder:after {content:"";}
#inputFormBorder0 :-ms-input-placeholder:after {content:"";}
input {width:300px;}
</head>
<body>
<h4>this only works in chrome</h4>
<div id="inputFormBorder">
<input name="UserName" type="text" id="UserName" placeholder="User Name or Email">
<div>
<br><br>
<h4>cross browser?</h4>
<div id="inputFormBorder0">
<input name="UserName" type="text" id="UserName" placeholder="User Name or Email*">
<div>
<br><br>
<div id="inputFormBorder">
js turned this red *
<div>
<script>
$('#inputFormBorder0').each(function () {
$(this).html($(this).html().replace(/(\*)/g, '<span style="color: red;">*</span>'));
});
</script>
</body>
https://jsfiddle.net/zo16ruxd/15/ https://jsfiddle.net/zo16ruxd/15/
this jsfiddle should explain better. 这个jsfiddle应该更好地解释。
Thanks! 谢谢!
you mean something like this? 你的意思是这样的吗? https://jsfiddle.net/zo16ruxd/17/ if yes, why not use <span>
? https://jsfiddle.net/zo16ruxd/17/如果是,为什么不使用<span>
?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.