jQuery hide() 以及其示例
jQuery 中的 hide() 方法用於隱藏選定的元素。
語法
語法如下所示 −
$(selector).hide(speed,easing,callback)
上面,引數 speed 是隱藏效果的速度,而 easing 是元素在動畫不同時刻的速度。回撥函式是在 hide() 方法完成後執行的函式。
示例
現在讓我們來看一個實現 jQuery hide() 方法**的示例 −
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".btnhide").click(function(){
$("p").hide();
});
$(".btnshow").click(function(){
$("p").show();
});
});
</script>
</head>
<body>
<h2>Exam Info</h2>
<p>Examination begins on 24th December. The students are requested to submit project report before 15th December.</p>
<button class="btnhide">Hide</button>
<button class="btnshow">Display</button>
</body>
</html>輸出
此操作將生成以下輸出 −

點選“隱藏”按鈕將隱藏資訊 −

現在,透過點選“顯示”再次顯示 −

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