为什么用js控制超链接样式后,a:hover效果就失效了? 本帖最后由 largegy 于 2011-07-03 09:52:14 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <!DOCTYPE html><html> <head> <title>Test</title> <meta http-equiv="Content-Type" content="text/html;charset=gb2312" /> <style type="text/css"><!-- a:hover { color:red; } --></style> </head> <body> <a href="#" id="test">fffffffffffffffffff</a> <script> document.getElementById('test').style.background = 'blue' </script> </body></html>没问题啊楼主 把 你得 demo 贴上来呢? 但是给a:hover加上图片背景就不行了,如果去掉js控制,图片背景就行显示出来,执行js后,图片背景就失效了!<!DOCTYPE html><html> <head> <title>Test</title> <meta http-equiv="Content-Type" content="text/html;charset=gb2312" /> <style type="text/css"><!-- a:hover { color:red; background:url(nav2.gif)} --></style> </head> <body> <a href="#" id="test" >fffffffffffffffffff</a> <script> document.getElementById('test').style.background = 'blue' </script> </body></html> <script>document.getElementById('test').style.backgroundColor = 'blue' </script>这样试试 。 把js中的background改为background-color就好`` 这个document.getElementById('test').style.background = 'blue' 把a:hover中的background覆盖了. 大神过来看看!!两个js冲突,求解救!!!!! 正则 问题 100分求JAVASCRIPT如何读取反序列化JSON后的对象 在线等待: 如何将一个DIV内容标记为选中? 请问能不能一次性定义所有的 <INPUT>的onfocus='BLUR()' document.forms[0].name结果是[object] 为什么我用的JavaScript图片循环显示时表格与表格之间有个缝隙? 请教一个简单问题! 如何在IE6 SP1下resizeto 一个 fullscreen=1的页面 表格如何增加一列?或者一行? 求js 正则表达式 固话加手机 新手请教EXT界面的问题
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
<style type="text/css"><!--
a:hover { color:red; }
--></style>
</head>
<body>
<a href="#" id="test">fffffffffffffffffff</a>
<script>
document.getElementById('test').style.background = 'blue'
</script>
</body>
</html>没问题啊
楼主 把 你得 demo 贴上来呢?
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
<style type="text/css"><!--
a:hover { color:red; background:url(nav2.gif)}
--></style>
</head>
<body>
<a href="#" id="test" >fffffffffffffffffff</a>
<script>
document.getElementById('test').style.background = 'blue'
</script>
</body>
</html>
document.getElementById('test').style.backgroundColor = 'blue'
</script>
这样试试 。