JS實現鼠標經過不同鏈接顯示不同背景顏色。用鏈接改變網頁的背景顏色,鼠標只要放在鏈接上面,網頁的背景色即變換,代碼中,使用JavaScript的document.bgColor方法通過設定bgcolor屬性來改變背景色為指定地顏色。至于需要變成什么顏色,這個由您來決定,你可以自定義這些顏色。
演示:
<html><head><title>鏈接驅動背景色</title><style type="text/css"><!--A {COLOR: 000000; FONT-SIZE: 9pt; FONT-WEIGHT: 400; TEXT-DECORATION: none }--></style><script><!--function cbgcolor(color){ //改變背景色document.bgColor=color //通過設定bgcolor屬性來改變背景色為指定地顏色。}//--></script></head><body><table border="1" width="100%" height="278"><tr><td width="50%" align="center" height="139"><a href=# onMouseOver="cbgcolor('#ff0000')"><b>新浪sina(鏈接色:紅色)</b></a></td><td width="50%" align="center" height="139"><a href=# onMouseOver="cbgcolor('#ff8080')"><b>網易163(鏈接色:粉紅)</b></a></td></tr><tr><td width="50%" align="center" height="139"><a href=# onMouseOver="cbgcolor('#ff8040')"><b>網wfuyu.com(鏈接色:金黃)</b></a></td><td width="50%" align="center" height="139"><a href=# onMouseOver="cbgcolor('#0080ff')"><b>搜狐soho(鏈接色:淺藍)</b></a></td></tr></table></body></html><div style="text-align:center;margin:30px 0 0 0;"><hr style="color:#999;height:1px;">如不能顯示效果,請按Ctrl+F5刷新本頁,更多網頁代碼:<a href='http://www.vxbq.cn/' target='_blank'>http://www.vxbq.cn/</a></div>提示:可修改后代碼再運行!
上一篇 清空SQL Server數據庫中所有表數據的方法
下一篇 SQL SERVER基礎:操作與命令大全
程序員人生,我編程,我富裕,記住wfuyu網,php教程,php學習,php手冊,CMS模版制作
聲明:本站大部分內容是作者原創,少部分收集于互聯網供大家一起學習,原版權很多不明,如有侵權請聯系本站,謝謝!
粵ICP備14040726號-1?? 2015-2020 程序員人生 版權所有