To add a tooltip to an HTML page, you can use the title, ALT, and popup methods.
1. Use the title attribute
Syntax <
Element Title ="
Value ">... </
Element >
Example: <a id = "myl"
Title = "this is a link" Href = "http://www.cnblogs.com/leeym/" target = _ blank> blog address </a>
Title can be used for most page elements
2. Use the alt attribute
ALT is a read/write attribute.
Syntax document. getelementbyid (" Elementid "). Alt = Value
Example:
<SCRIPT>
Function B1 (){
Document. getelementbyid ("myimg"). ALT = 'This is the blog garden logo' ;}
</SCRIPT>
ALT is used only for <area>, , <input>, <APPLET>, and <Object> (the last two are only applicable to nn6 and IE6)
3. Use a popup object
Popup is a JavaScript Object and provides powerful prompt functions, because its prompt content is in HTML format.
Example:
<Script language = "JavaScript">
// Popup object 1
VaR popup1 = Window. createpopup ();
Popup1.document. Body. innerhtml = 'display 1 ';
Popup1.document. Body. style. backgroundcolor = 'green ';
Popup1.document. Body. style. color = "white ";
// Popup object 2
VaR popup2 = Window. createpopup ();
Popup2.document. Body. innerhtml = 'display 2 ';
Popup2.document. Body. style. backgroundcolor = 'green ';
Popup2.document. Body. style. color = "red ";
</SCRIPT>
<Div onmouseover = "popup1.show (40, 40,200,100, document. Body);" onmouseout = "popup1.hide ();" style = "cursor: Hand">
Move the cursor to this 1 </div>
<Div onmouseover = "popup2.show (40, 60,200,100, document. Body );"
Onmouseout = "popup2.hide ();" style = "cursor: Hand">
Move the mouse over 2 </div>
In addition, you can use the tooltip attribute on the Web Server Control in Asp.net to implement the prompt.