![](/img/trans.png)
[英]why I see html tag in php using tinymce textarea for input?
[英]How to set the colour of a text in a textarea using html input tag
HTML
<form name="myform">
Select Color : <input type="color" onClick="Color()">
</form>
<textarea name="myTextArea" id="myTextArea" cols="100" rows="14" placeholder="Enter Text Here ..."></textarea>
使用Javascript
function Color() {
document.getElementById("myTextArea").style.color = '';
}
我在这里做错了什么?
以同样的方式,我将如何为文本区域中的特定单词设置特定的字体(家庭字体)。
使用onkeyup
代替onclick
。
HTML
<form name="myform">
Select Color : <input type="color" onkeydown="Color(this.value)">
</form>
<textarea name="myTextArea" id="myTextArea" cols="100" rows="14" placeholder="Enter Text Here ..."></textarea>
JS
function Color(s){
document.getElementById("myTextArea").style.color = s;
}
对于输入类型的颜色,使用onchange
事件是有意义的。 它将根据您的需要工作:
<input type="color" onchange="Color(this)">
JS
function Color(obj) {
document.getElementById("myTextArea").style.color = obj.value;
}
您可以执行类似的操作以将选定的颜色应用于文本。
<input type="color" onClick="Color(this)">
function Color(cthis){
document.getElementById("myTextArea").style.color = cthis.value
}
要应用的字体famly成元素textarea
,你可以做这样的事情。
document.getElementById("myTextArea").style.fontFamily="Arial";
像这样做:
<input type="color" id="color"/>
使用一些jQuery:
$("#color").change(function(){
var clr = $(this).val();
$("#myTextArea").css("color",clr);
});
没有OnClick或其他让jQuery完成的事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.