在 jQuery 中懸停文字框時顯示提示文字
為此,請使用 jQuery(selector)。toolTip()。
示例
下面是程式碼:-
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<body>
<label>Write Your Favourite Subject Name:</label>
<input id="demoTooltip" title="Your Favourite Subject may be JavaScript...">
</body>
<script>
jQuery(".demoTooltip").toolTip()
</script>
</html>若要執行上述程式,請將檔名儲存為 anyName.html(index.html)。右鍵單擊該檔案,並選擇 VS Code 編輯器中的“使用 Live Server 開啟”選項。
輸出
輸出如下所示

將滑鼠懸停在文字框內時,您將得到提示 -
Your Favourite Subject may be JavaScript...
還顯示在以下螢幕截圖中 -

廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
JavaScript
PHP