Change image title on mouse over event using java

Discussion in 'JavaScript' started by DazedAndConfused, Dec 20, 2007.

  1. #1
    Hello,

    I am extremely new to Java and I was just wondering if there is some simple command that will change the title of an image on a mouse over event. I have a small script worked out that changes the image src on a mouseover but I haven't been able to figure out a way to change the title of the image as well. My script is as follows:
    <script language="JavaScript">

    var ResearcherImage = new Array();
    var ResearcherText = new Array();

    ResearcherImage[0] = "Images/Button.gif";
    ResearcherImage[1] = "Images/Clear_Button.gif";

    ResearcherText[0] = "Button Image";
    ResearcherText[1] = "Clear Button Image";

    function changeImage(whichImage)
    {
    if (document.body)
    {
    document.images["Researcher"].src = ResearcherImage[whichImage]; **Researcher is the name of the image**
    }
    }
    </script>

    The html code for the link is:
    <td id="grey_links"><a href="#" onMouseOver="javascript:changeImage(0)">Change</a></td>

    The html for the img that is being altered is:
    <img src="Images/Biography.gif" name="Researcher" title="" />

    Thanks
     
    DazedAndConfused, Dec 20, 2007 IP
  2. sunnyverma1984

    sunnyverma1984 Well-Known Member

    Messages:
    342
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    120
    #2
    use
    <img src="image.gif" onmouseover="this.title='title1'" onmouseout="this.title='title2'" >
     
    sunnyverma1984, Dec 20, 2007 IP