<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI 工具提示框(Tooltip) - 自定义内容</title>
<link rel="stylesheet" href="//apps.bdimg.com/libs/jqueryui/1.10.4/css/jquery-ui.min.css">
<script src="//apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//apps.bdimg.com/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
<link rel="stylesheet" href="jqueryui/style.css">
<style>
.photo {
width: 300px;
text-align: center;
}
.photo .ui-widget-header {
margin: 1em 0;
}
.map {
width: 350px;
height: 350px;
}
.ui-tooltip {
max-width: 350px;
}
</style>
<script>
$(function() {
$( document ).tooltip({
items: "img, [data-geo], [title]",
content: function() {
var element = $( this );
if ( element.is( "[data-geo]" ) ) {
var text = element.text();
return "<img class='map' alt='" + text +
"' src='http://maps.google.com/maps/api/staticmap?" +
"zoom=11&size=350x350&maptype=terrain&sensor=false¢er=" +
text + "'>";
}
if ( element.is( "[title]" ) ) {
return element.attr( "title" );
}
if ( element.is( "img" ) ) {
return element.attr( "alt" );
}
}
});
});
</script>
</head>
<body>
<div class="ui-widget photo">
<div class="ui-widget-header ui-corner-all">
<h2>圣史蒂芬大教堂(St. Stephen's Cathedral)</h2>
<h3><a href="//maps.google.com/maps?q=vienna,+austria&z=11" data-geo="">奥地利维也纳(Vienna, Austria)</a></h3>
</div>
<a href="//en.wikipedia.org/wiki/File:Wien_Stefansdom_DSC02656.JPG">
<img src="/wp-content/uploads/2014/03/st-stephens.jpg" alt="圣史蒂芬大教堂(St. Stephen's Cathedral)" class="ui-corner-all">
</a>
</div>
<div class="ui-widget photo">
<div class="ui-widget-header ui-corner-all">
<h2>塔桥(Tower Bridge)</h2>
<h3><a href="//maps.google.com/maps?q=london,+england&z=11" data-geo="">英国伦敦(London, England)</a></h3>
</div>
/**代码未完, 请加载全部代码(NowJava.com).**/
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。