SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Dec 2011
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript mouse over (multiple use problem)

    Hi Everybody,

    I am having difficulties with a javascript mouseover. This is what I have in the head:
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    loadbutton1 = new Image();
    loadbutton1.src = "small2.jpg";
    staticbutton1 = new Image();
    staticbutton1.src = "small1.jpg";
    // End -->
    </script>


    in the body I have:
    <img name="button1" src="small1.jpg" width="30" style="border-width: 0px;" />

    however I want to use this multiple times on the webpage (with the mouse over of course) and it will not work more than once, how can I change this so it works?

    thank you in advance!

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,786
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    <SCRIPT type="text/javascript">
    loadbutton1 = new Image();
    loadbutton1.src = "small2.jpg";
    staticbutton1 = new Image();
    staticbutton1.src = "small1.jpg";
    </script>

    <img name="button1" src="small1.jpg" width="30" style="border-width: 0px;" onmouseover="this.src=small2.jpg" onmouseout="this.src=small1.jpg" />
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Bookmarks

Posting Permissions

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