Solved

jQuery Image Over Text - How?

Posted on 2010-09-05
7
310 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
ID: 33608290
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
ID: 33608301
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
ID: 33608310
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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

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

Expert Comment

by:leakim971
ID: 33617236
You're welcome!
0
 

Author Closing Comment

by:SrinathS
ID: 33764655
Solved.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33764715
Thanks for the points!
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

828 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