<div> <h1>tooltip</h1> <hr /> <p> 给某个元素或者页面上含有 title 属性的元素设置一个统一样式的 tooltip。 </p> <h2>setTooltip</h2> <code>function setTooltip(container: HTMLElement, content: string | HTMLElement): void</code> <h3>container: HTMLElement</h3> <p> 要设置 tooltip 的元素 </p> <h3>content: string | HTMLElement</h3> <p> 要设置的 tooltip 内容,允许为字符串或者 HTML 元素 </p> <h2>resolveTooltip</h2> <code>function resolveTooltip(container?: HTMLElement): HTMLElement</code> <h3>container?: HTMLElement</h3> <p> 给此元素,为 null 则把 document.body 下的所有含有 title 属性的子元素设置成统一样式的 tooltip </p> <hr /> <h2>示例</h2> <pre><div id="tooltip-sample"> <!-- 1 --> <blockquote title="From MDN Website">To send an HTTP request, create an XMLHttpRequest object, open a URL, and send the request. After the transaction completes, the object will contain useful information such as the response body and the HTTP status of the result.</blockquote> <!-- 2 --> <button title="Test to send request through XMLHttpRequest.">Test</button> </div> <script type="text/javascript"> window["lib-ui"].resolveCheckbox(document.querySelector("#checkbox-sample")); </script></pre> <div id="tooltip-sample"> <blockquote title="From MDN Website">To send an HTTP request, create an XMLHttpRequest object, open a URL, and send the request. After the transaction completes, the object will contain useful information such as the response body and the HTTP status of the result.</blockquote> <button title="Test to send request through XMLHttpRequest.">Test</button> </div> <script type="text/javascript"> window["lib-ui"].resolveTooltip(document.querySelector("#tooltip-sample")); </script> </div>