当鼠标移动到一个层div1时,div1里面有div2,div2里面的文字变白色,怎么写代码,谢谢啊!

解决方案 »

  1.   

    HTML也不贴出。参考下面:<div id="demo" style="width:100px;height:100px;border:1px solid blue;background:red;">
          sssssssssssssss
            <div id="inner">test hello</div>
    </div>
    <script>
       document.getElementById('demo').onmouseover=function(){
              document.getElementById('inner').style.color='white';
       }
       document.getElementById('demo').onmouseout=function(){
              document.getElementById('inner').style.color='';
       }
    </script>
      

  2.   

    我把代码发给你你帮我看哈啊
    <style type="text/css">
    .hot { background: url(image/01.jpg) no-repeat; height: 293px;width: 202px; margin-top: 55px; margin-left: 137px; float: left; cursor:hand;}
    .hot_e { background: url(image/02.jpg) no-repeat; height: 293px;width: 202px; margin-top: 55px; margin-left: 137px; float: left; cursor:hand; color: #ffffff;}
    .hot_t { height: 132px; width: 183px; float: left; margin-left: 11px; margin-top: 8px;}
    .hot_1 { height: 42px; width: 125px; margin-left: 62px; margin-top: 16px; float: left;}
    .hot_2 { height: 46px; width: 170px; float: left; margin-top: 8px; margin-left: 15px;}
    </style>
     <div class="hot" onMouseOver="className='hot_e'" onmouseout="this.className='hot'" title="三大优惠 五次惊喜 马上" onClick="window.location.href='index.html'">
       <div class="hot_t"><img src="image/x1.jpg"></div>
       <div class="hot_1"><span class="STYLE7">hot events</span><br><span class="STYLE8">三大优惠 五次惊喜 马上</span></div>
       <div class="hot_2"><span class="STYLE9">三大优惠 五次惊喜 马上开启 72小时疯狂抢定惠活动马上就开始啦!诚...</span></div>
      

  3.   

    hot_1里面的“三大优惠 五次惊喜 马上”和hot_2里面的“三大优惠 五次惊喜 马上开启 72小时疯狂抢定惠活动马上就开始啦!诚...”都要变白色,原来都是由 STYLE7 STYLE8 STYLE9 控制的,现在是当鼠标移到hot这个层时,就变白色,谢谢你啊!那怎么写代码?
      

  4.   

    <div class="hot_1" onmouseover="this.style.color='white'" onmouseout="this.style.color=''" ><span class="STYLE7">hot events</span><br><span class="STYLE8">三大优惠 五次惊喜 马上</span></div>这样试试。。
      

  5.   

    你教我,怎么用
    <div id="demo" style="width:100px;height:100px;border:1px solid blue;background:red;">
          sssssssssssssss
            <div id="inner">test hello</div>
    </div>
    <script>
       document.getElementById('demo').onmouseover=function(){
              document.getElementById('inner').style.color='white';
       }
       document.getElementById('demo').onmouseout=function(){
              document.getElementById('inner').style.color='';
       }
    </script>
    就是刚才给我的这个改背景为另一张图片,本来是background: url(image/01.jpg),怎么让它当鼠标一上去的时候变为background: url(image/02.jpg)
      

  6.   

    document.getElementById('inner').style.color='white';这行下面加上:
          this.style.background='url(image/01.jpg)';  //确保路径正确。鼠标移开换回原来背景。
       this.style.background='red'; 
      

  7.   

    加上这个<span class="STYLE1">test hello</span>后,里面的字没有变白啦,
      

  8.   


    function bianse(){
    //鼠标移到hot DIV时,DIV hot_2里的文字变色
    document.getElementById('hot').onmouseover=function(){
              document.getElementById('hot_2').style.color='white';
    }
    document.getElementById('hot').onmouseout=function(){
              document.getElementById('hot_2').style.color='';
    } }
      

  9.   

    小弟初学javascript,很有兴趣,楼主的这个问题似乎过于简单,我认为你应该自己动手解决,我这几天在学习DOM, 出了好多问题,我都慢慢的调试好了。
    希望你能采纳!
      

  10.   

    我用jquery实现的  你可以看看啊 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>    <script src="js/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(function() {
                $("#demo").mouseover(function() {
                    $("#inner").css("background-color", "white");
                });
                $("#demo").mouseout(function() {
                    $("#inner").css("background-color", "");
                });
            })  
             
        </script></head>
    <body>
       <div id="demo" style="width:100px;height:100px;border:1px solid blue;background:red;">
          sssssssssssssss
            <div id="inner">test hello</div>
    </div>
    </body>
    </html>希望对你有所帮助。
      

  11.   

    这个问题用css就可以解决,不需要用到js<style type="text/css">
    body{background:blue;}
    .div1{padding:20px;border:1px solid;}
    .div1:hover .div2{color:white;}
    </style><div class="div1">
    <div class="div2">hello world</div>
    </div>
      

  12.   

    各位大虾,帮帮忙啊,我快崩溃啦!你们就教我怎么做像巴黎春天http://www.tzps.com/首页的热门活动的那种效果,当鼠标一上去背景变色,字也变色,要的是那种效果,那应该怎么做啊?代码怎么写?
      

  13.   

    <span><b>hot events</b><i>三大优惠 五次惊喜 马上</i></span><small>三大优惠 五次惊喜 马上开启 72小时疯狂抢定惠活动马上就开始啦!诚...</small>
     这个是它那的代码