input中默认值和输入值颜色不同

默认值和用户输入的 样式 如何才能弄的不一样。
比如:
<input type="text" id="test" value="格式为[email protected]" onfocus="cls()" onblur="res()"/>
默认值:格式为[email protected]为灰色字,
用户输入:比如[email protected]为黑色字。
<input type="text" id="test" value="格式为[email protected]" onfocus="cls()" onblur="res()" style="color:gray;" onkeyprese="pre(this)"/>

pre = new function(el)
{
el.style.color = "black";
}

你可能感兴趣的:(JavaScript,html)