在 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...

還顯示在以下螢幕截圖中 -

更新於: 03-10-2020

2K+ 瀏覽量

開啟職業生涯

完成課程並獲得認證

開始
廣告
© . All rights reserved.