Solved

jQuery Image Over Text - How?

Posted on 2010-09-05
7
294 Views
Last Modified: 2012-06-27
Hello,

I would like to display an image when I mouse over particular text in a webpage. i.e., I need to display the user image when I mouse over each user name. The webpage is developed purely in HTML. Any further resources / scripts would be greatly appreciated! Thanks!
0
Comment
Question by:SrinathS
  • 4
  • 3
7 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
Comment Utility
Check this :


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script language="javascript">
	$(document).ready(function() {
		$(".pic").hide();
		$(".txt").hover(function(e) {
				$(".pic").css({"position":"absolute", "left":e.pageX, "top":e.pageY}).toggle();
		});
	});
</script>
</head>
<body>
<table>
<tr><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td></tr>
<tr><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td></tr>
<tr><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td></tr>
<tr><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td></tr>
<tr><td>text</td><td>text</td><td>text</td><td>text</td><td class="txt"><b>COME HERE</b></td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td></tr>
<tr><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td></tr>
<tr><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td></tr>
<tr><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td><td>text</td></tr>
</table>
<div class="pic"><img src="http://www.usefilm.com/images/4/6/7/0/4670/1195576-medium.jpg" /></div>
</body>
</html>

Open in new window

0
 

Author Comment

by:SrinathS
Comment Utility
Wow! I understand the basic usage. How can I customize the mouse over effect? i.e., Currently it's displaying the image suddenly. I would like to display an image above text. I mean how can I get smoother rollover effect?
Thanks for your quick response!
0
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 500 total points
Comment Utility
you can use delay in toggle for example : toggle("slow")

http://api.jquery.com/toggle/

Check slideToggle too : http://api.jquery.com/slideToggle/

Other jQuery effect : http://www.w3schools.com/jquery/jquery_effects.asp
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:SrinathS
Comment Utility
Good to see your reply. I will implement this tonight. Thanks.
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
You're welcome!
0
 

Author Closing Comment

by:SrinathS
Comment Utility
Solved.
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
Thanks for the points!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now