案例:jQuery UI案例     状态:可编辑再运行    进入竖版
 运行结果 
AخA
<p>所有的图片源自 <a href="//commons.wikimedia.org/wiki/Main_Page">Wikimedia Commons</a>,且归 <a href="//creativecommons.org/licenses/by-sa/3.0/deed.en" title="Creative Commons Attribution-ShareAlike 3.0">CC BY-SA 3.0</a> 下版权持有人所有。</p>
 
1
<!doctype html>
2
<html lang="en">
3
<head>
4
  <meta charset="utf-8">
5
  <title>jQuery UI 工具提示框(Tooltip) - 自定义内容</title>
6
  <link rel="stylesheet" href="/css/jqu1.10.4/jquery-ui.min.css">
7
  <script src="/js/jqu/jquery.min1.10.2.js"></script>
8
  <script src="/js/jqu/jquery-ui.min1.10.4.js"></script>
9
  <link rel="stylesheet" href="jqueryui/style.css">
10
  <style>
11
  .photo {
12
    width: 300px;
13
    text-align: center;
14
  }
15
  .photo .ui-widget-header {
16
    margin: 1em 0;
17
  }
18
  .map {
19
    width: 350px;
20
    height: 350px;
21
  }
22
  .ui-tooltip {
23
    max-width: 350px;
24
  }
25
  </style>
26
  <script>
27
  $(function() {
28
    $( document ).tooltip({
29
      items: "img, [data-geo], [title]",
30
      content: function() {
31
        var element = $( this );
32
        if ( element.is( "[data-geo]" ) ) {
33
          var text = element.text();
34
          return "<img class='map' alt='" + text +
35
            "' src='http://maps.google.com/maps/api/staticmap?" +
36
            "zoom=11&size=350x350&maptype=terrain&sensor=false&center=" +
37
            text + "'>";
38
        }
39
        if ( element.is( "[title]" ) ) {
40
          return element.attr( "title" );
41
        }
42
        if ( element.is( "img" ) ) {
43
          return element.attr( "alt" );
44
        }
45
      }
46
    });
47
  });
48
  </script>