说明:上面的"t"可以根据自己需要修改,具体代码参考:
<html>
<body>
<a name="t" class="STYLE2" id="t" onclick="chcolor()">登陆通行证</a>
<script type="text/javascript">
function chcolor(){
document.getElementById("t").style.color="red"
}
</script>
</body></html>
用JavaScript动态改变按钮文字上面的颜色:<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function initArray() {
for (var i = 0i <initArray.arguments.lengthi++) {
this[i] = initArray.arguments[i]
}
this.length = initArray.arguments.length
}
var colors = new initArray(
"red",
"blue",
"green",
"purple",
"black",
"tan",
"yellow",
"lime",
"coral",
"palegreen",
"silver",
"gold",
"red")
delay = .5// seconds
link = 0
vlink = 0
function linkDance() {
link = (link+1)%colors.length
vlink = (vlink+1)%colors.length
document.linkColor = colors[link]
document.vlinkColor = colors[vlink]
setTimeout("linkDance()",delay*1000)
}
linkDance()
// End -->
</script>
看看这个代码是不是你要的<script
type="text/javascript">
function
colors(color){
var
str=color.innerHTML
var
kk=str.replace(/变色/,
"<span
style='color:#FF0000'>变色</span>")
color.innerHTML=kk
}
</script>
<div
id="test">
测试文字变色
</div>
<a
href="javascript:colors(test)">innerHTML内容</a>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)