网页制作javascript鼠标经过文字变色问题

JavaScript013

网页制作javascript鼠标经过文字变色问题,第1张

<style type="text/css">

body,td,th {

font-size: 18px

color: #999

font-weight: bold

}

上面已经设置了td,th文字颜色属性,

<td width="62"><div align="center"><a href=page1.html style="color='#999'cursor:hand" onmouseover="javascript:this.style.color='red'" 

onmouseout="javascript:this.style.color='#999'">游戏介绍</a></div></td>

这里又设置了颜色属性,不过行内样式优先,可以改成style="color=blue............",这时即:

<style type="text/css">

body,td,th {

font-size: 18px

color: #999

font-weight: bold

} <td width="62"><div align="center"><a href=page1.html style="color='blue'cursor:hand" onmouseover="javascript:this.style.color='red'" 

onmouseout="javascript:this.style.color='#999'">游戏介绍</a></div></td>

这时颜色body,td,thcolor属性已经不起作用了也可以下面这样,去掉行内style="color:#999",行内的color属性去掉 前边color设置成你要的其实颜色。

<style type="text/css">

body,td,th {

font-size: 18px

color: blue

font-weight: bold

}

<td width="62"><div align="center"><a href=page1.html style="cursor:hand" onmouseover="javascript:this.style.color='red'" 

onmouseout="javascript:this.style.color='#999'">游戏介绍</a></div></td>

有点乱,希望有帮助!

a:hover

{

color:blue

}

刚才朋友的打法要注意在ie6下超链接里面的href为空或者不写的话是没有效果的,这是一个bug,解决的话就得用js了,

$('a').hover(function(){

$(this).css(''color','blue')

},function(){

$(this).css(''color','black')})

希望采纳

给你两个个思路:一:定义一个字体大小和颜色两个数组,再定义鼠标滑过事件,随机获取数组中的字体大小和颜色值。

二:随机颜色生成方法如下

function randomColor( ) {      var rand = Math.floor(Math.random( ) * 0xFFFFFF).toString(16)      if(rand.length == 6){          return rand      }else{          return randomColor()      }

字体大小方法自己琢磨实现吧,核心方法就是:Math.random()生成随机数