473,382 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Change image when mouse hovers over href (image is smaller than href area)

I have the text "site" and right of it "img_1.gif".
I currently have it setup (through CSS) so that once the mouse hovers "site" it changes color. However to change the "img_1.gif" to "img_2.gif" you must hover the mouse over the .gif.

I would like it setup so that hovering over "site" will also change the image from "img_1.gif" to "img_2.gif" without having to use CSS.

Any help would be greatly appreciated.

Expand|Select|Wrap|Line Numbers
  1. <a href="site.html">
  2.  site
  3. <img src="img_1.gif"
  4. onmouseover="this.src='img_2.gif'"
  5. onmouseout="this.src='img_1.gif'" />
  6. </a>
  7.  
Nov 4 '10 #1
3 3642
drhowarddrfine
7,435 Expert 4TB
You should ask javascript questions on the javascript board but why don't you want to use CSS to do this?
Nov 4 '10 #2
I will probably end up using CSS. I thought there may be an easy solution I was unaware of. The reason I didn't want to use CSS was because in HTML the image sits in the correct place every time. If I was to put it in CSS (to my knowledge) I would have to do a custom "id" for every image.

In the process of writing this message I remembered that I can do a "float: right;" in CSS. This would allow the image to sit in the correct place of every title.

Thanks anyways.
Nov 4 '10 #3
Death Slaught
1,137 1GB
CSS is the easy solution. You wouldn't need a different id for every image. You can use the class attribute for each one and achieve the same affect. Unless you are doing this with several sets of images?

As for the JavaScript,

You could just give the image an id and use document.getElementById('') to change the source. Just be conscious of the single quotes.

Expand|Select|Wrap|Line Numbers
  1. <a href="site.html" onmouseover="document.getElementById('siteImage').src='img_2.gif'" 
  2. onmouseout="document.getElementById('siteImage').src='img_1.gif'">
  3.  site
  4. <img id="siteImage" src="img_1.gif"
  5. onmouseover="this.src='img_2.gif'"
  6. onmouseout="this.src='img_1.gif'" />
  7. </a>


Regards, Death
Nov 5 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Jay | last post by:
Hi, How can I capture mouse position on Image? I found number of script capturing mouse position of the page. But I could not find anything based on image. What I want to find out is X Y...
1
by: Bart Lateur | last post by:
I'd like to replace the text content of a subdiv by "...", except when the mouse is hovering either above it, or above another subdiv of the same parent. Something like: <div class="parent">...
1
by: sharma1985 | last post by:
Hi all, I m worhing on creating an user intractive scatter graph images which contains thousands of points on it. So,I would like to know that how could i display the coordinates of every...
0
by: mshiva | last post by:
Hi, I am working on Repeater control in Asp.net2.0 which has image button within it. I want to fire image button click event to display the image in a large view. Can anyone help me
5
by: kimiraikkonen | last post by:
Hi, I couldn't find a necessary class which shows when mouse hovers on a link in Webbrowser control. Think of there's a status bar(text), when mouse comes on a link, the URL must be shown in...
3
by: kashhere | last post by:
hi actually i need a help on image enlargening i had an image if i click on that image then that image should be opened in a small fixed child window and that tooo enlargened how can i do that...
1
by: sonysunny | last post by:
How can we display a box (like tool tip, bigger than tool tip box and can be customised) when mouse is placed over an image and disappear wen mouse removed from that image. Using javascript. ...
0
by: sgl | last post by:
Access 2007 - Very annoying to have a (rather long) string displayed each time I hover my mouse on a linked table. Especially when I'm trying to read information on an open table on the right. ...
19
by: andersond | last post by:
I want the text to change from gray to bright red when the mouse is moved over the name of our company. Here is the code that doesn't work. What do I need to change to make this work? function...
5
mariko
by: mariko | last post by:
I have some pictures on a web page and I want them to "get bigger" when the mouse hovers over them. With the little research I've done, it seems like it would be a rollover effect and something I can...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.