【发布时间】:2014-01-16 18:19:53
【问题描述】:
如何根据 jquery 中的输入值更改字体颜色?
这是我的代码
<h3 id="quoteDiv"></h3>
<input id="input1" type="text" onfocus="if(this.value == 'Valfri spelare') { this.value = ''; }" value="Valfri spelare"/>
var quotes = ["(tjej1) exampletext!",];
var user1 = document.getElementById("input1").value;
//Sub in the usernames
var ind = Math.floor(Math.random() * quotes.length); //select random quote
var newquote = quotes[ind].replace("(tjej1)", user1);
var quotediv = document.getElementById("quoteDiv"); //get the div (or any other element) that you want to display the quote in
quotediv.innerHTML = newquote; //display your quote in the div.
如何将值的颜色从 input1 (tjej1) 更改为绿色而不是标准的 h3?我只希望值改变颜色:)
谢谢!
【问题讨论】:
标签: jquery input colors quotes