473,799 Members | 3,005 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3654
drhowarddrfine
7,435 Recognized Expert Expert
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 Top Contributor
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.getEle mentById('') 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
14730
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 coordinates of mouse position. based on left of the top of my image is 0 0 (X Y coordinates) otherwise, I need to find out position of my image so I can calculate.
1
2252
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"> <span class="name"><a href="#">Name</a></span>: <span class="message">This is the text</span> </div> div.parent span.message { display: none }
1
1903
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 point on a scatter graph using javascript, when user mves their mouse pointer over each point shown in the graph. i also want to know that can i fetch information regarding each point directly from the my database tables when i moves mouse over the...
0
899
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
8080
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 this status bar. How can i do this? Thanks.
3
1509
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 please guide me towards the solution thanks in advance
1
1481
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. thanks in advance
0
1232
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. Is it possible to disable this feature? Thanks
19
16147
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 mouseOver(){ document.getElementById('unitedBrokers').style.font="size='2' face='Arial color='#FF0000'"; }// mouseOver() function mouseOut(){ document.getElementById('unitedBrokers').style.font="size='2' face='Arial color='#808080'"; }//...
5
2336
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 do with CSS. I don't want to use javascript. The coding seems to need an image that is divided into the number of needed effects. But that would be problematic because I want images of different sizes and the source image couldn't be split into the...
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10482
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10251
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9072
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7564
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4139
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.