在鼠标悬停时触发事件,并使用元素的数据描述来显示详细信息:
<option onmouseover="displayDescription(this)" onmouseout="hideLabel()" data-server-description="your_description" id='1'> Server1 </option> <script> function displayDescription(ele) { // You can use the data-server-description attribute to catch the description var server_data = ele.data-server-description; // you can also use the ID to fetch the description if not embadded in as an html attribute var server_id = ele.id; document.getElementById('your_label_id').innerHTML = server_data; } function hideLabel() { document.getElementById('your_label_id').innerHTML =''; } </script>
如果您使用的是bootstrap
<a href="#" data-toggle="tooltip" title="server 1 description">server 1</a> <a href="#" data-toggle="tooltip" title="server 2 description">server 2</a> <a href="#" data-toggle="tooltip" title="server 3 description">server 3</a>
只需这些代码就行了。
请检查并运行以下代码:
<a href="#" title="server 1 description">server 1</a><br> <a href="#" title="server 2 description">server 2</a><br> <a href="#" title="server 3 description">server 3</a>