编辑下面的代码:【加编码】
<html lang="en"> <head> <meta charset="utf-8"> <title>jQuery UI 工具提示框(Tooltip) - 自定义内容</title> <link rel="stylesheet" href="https://libs.baidu.com/jqueryui/1.10.4/css/jquery-ui.min.css"> <script src="https://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script> <script src="https://libs.baidu.com/jqueryui/1.10.4/jquery-ui.min.js"></script> <link rel="stylesheet" href="/demo/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&center=" + 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="http://maps.google.com/maps?q=vienna,+austria&amp;z=11" data-geo="">奥地利维也纳(Vienna, Austria)</a></h3> </div> <a href="http://en.wikipedia.org/wiki/File:Wien_Stefansdom_DSC02656.JPG"> <img src="/media/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="http://maps.google.com/maps?q=london,+england&amp;z=11" data-geo="">英国伦敦(London, England)</a></h3> </div> <a href="http://en.wikipedia.org/wiki/File:Tower_bridge_London_Twilight_-_November_2006.jpg"> <img src="/media/uploads/2014/03/tower-bridge.jpg" alt="塔桥(Tower Bridge)" class="ui-corner-all"> </a> </div> <p>所有的图片源自 <a href="http://commons.wikimedia.org/wiki/Main_Page">Wikimedia Commons</a>,且归 <a href="http://creativecommons.org/licenses/by-sa/3.0/deed.en" title="Creative Commons Attribution-ShareAlike 3.0">CC BY-SA 3.0</a> 下版权持有人所有。</p> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂