2015-12-28 102 views
1

我試圖用js,打造 「說明框」 一些 「信息文本」JS鼠標懸停,盤旋

HTML

<head> 
<script type="text/javascript" src="onmo.js"></script> 
</head> 
<body> 
    <div> <a onmouseover="info()" href="http://www.google.com"> google </a> </div> 
</body> 

JS

function info() {} 

我不知道哪些代碼用一些文本創建了所謂的「描述框」。 有幫助嗎?沒有css的 。

回答

1

您可以使用jquery-ui tooltip用於此目的。

這裏是用很好的例子,該文檔鏈接:Link

來自實例jqueryui網站:

<!doctype html> 
 
<html lang="en"> 
 
<head> 
 
    <meta charset="utf-8"> 
 
    <title>jQuery UI Tooltip - Default functionality</title> 
 
    <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> 
 
    <script src="//code.jquery.com/jquery-1.10.2.js"></script> 
 
    <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script> 
 
    <link rel="stylesheet" href="/resources/demos/style.css"> 
 
    <script> 
 
    $(function() { 
 
    $(document).tooltip(); 
 
    }); 
 
    </script> 
 
    <style> 
 
    label { 
 
    display: inline-block; 
 
    width: 5em; 
 
    } 
 
    </style> 
 
</head> 
 
<body> 
 
    
 
<p><a href="#" title="That&apos;s what this widget is">Tooltips</a> can be attached to any element. When you hover 
 
the element with your mouse, the title attribute is displayed in a little box next to the element, just like a native tooltip.</p> 
 
<p>But as it's not a native tooltip, it can be styled. Any themes built with 
 
<a href="http://jqueryui.com/themeroller/" title="ThemeRoller: jQuery UI&apos;s theme builder application">ThemeRoller</a> 
 
will also style tooltips accordingly.</p> 
 
<p>Tooltips are also useful for form elements, to show some additional information in the context of each field.</p> 
 
<p><label for="age">Your age:</label><input id="age" title="We ask for your age only for statistical purposes."></p> 
 
<p>Hover the field to see the tooltip.</p> 
 
    
 
    
 
</body> 
 
</html>

1

徘徊的鏈接時,這將告訴你一些文字:

<a href="http://www.google.com" title="This is Google"> google </a>

+0

是啊,我知道這個問題,但我特別需要JS – joki00

+0

@ joki00描述它應該看起來像 – CoderPi

+0

簡單的一個,用1個句子的「信息」喜歡與HTML標題選項 – joki00