A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [JS]problems with onmouseover

  1. #1
    Junior Member
    Join Date
    Dec 2005
    Posts
    25

    [JS]problems with onmouseover

    Hi I have problem with onmouseover - i am using this script:
    Code:
      <script type="text/javascript">
      last="d1";
      function f(x){
      document.getElementById(last).className='niewidoczna';
      document.getElementById(x).className='widoczna';
      last=x;
      }
      </script>
    and this css
    Code:
    .widoczna {
    display: block;
    }
    .niewidoczna {
    display: none;
    }
    . I made this sample - i have one img which is a button

    <a href="http://" onmouseover="f('d2')"><img src="picture.jpg" width="100px" height="20px"></a>

    As you know this is simple - when smb will move moouse over this picture, some picture in the div with id="d2" will be visible. Everything works fine but.. i want to use it for two divs. I have tried to use sth like that onmouseover="f('d2';'d3')" but it doesn't work. I want to change text in div d3, and picture in d2 - with one mouse over on that picture. Is any solution of my problem?

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518

    Maybe try something like this...

    Code:
    <html>
    <head>
    <STYLE type=text/css media=screen>
    BODY{margin:0; padding:0; background:#fff}
    .widoczna {display: block;}
    .niewid {display: none;}
    .hid {display: none;}
    </STYLE>
    <script type="text/javascript">
      oldpic="d1";
      oldtxt="d3";
      function f(pic,txt){
        document.getElementById(oldpic).className = 'niewid';
        document.getElementById(oldtxt).className = 'niewid';
        document.getElementById(pic).className = 'widoczna';
        document.getElementById(txt).className = 'widoczna';
        oldpic=pic;
        oldtxt=txt;
      }
    </script>
    </head>
    <body>
    <a href="http://" onmouseover="f('d2','d4')" onmouseout="f('d1','d3')">over here</a>
    <div id=d1>one</div>
    <div id=d2 class=hid>two</div>
    <div id=d3>three</div>
    <div id=d4 class=hid>four</div>
    </body>
    </html>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center