jQueryオブジェクトのhideメソッドを使うと、HTML要素の表示を隠して、非表示にすることができる。jQueryオブジェクトが複数のHTML要素にマッチする場合は、複数の要素を非表示にすることができる。
jQueryオブジェクトのhideメソッドには、同じ名前で引数が異なるオーバーロード(多重定義)された複数のメソッドが存在する。
jQueryObject.hide()
jQueryObject.hide(duration)
jQueryObject.hide(complete)
jQueryObject.hide(duration, complete)
jQueryObject.hide(options)
jQueryオブジェクトのhideメソッドは、戻り値としてjQueryオブジェクト自身を返す。
jQueryオブジェクトのhideメソッドには、以下に示す引数を指定できる。
<button id="b1">hide</button>
<button id="b2">show</button>
<img src="portrait.jpg" id="i1">
<script>
$(function() {
$('#b1').click(function() {
$('#i1').hide(1000);
});
$('#b2').click(function() {
$('#i1').show();
});
});
</script>
<button id="b3">hide</button>
<img src="portrait.jpg" id="i2">
<script>
$(function() {
$('#b3').click(function() {
$('#i2').hide(function(){
$('#i2').show()
});
});
});
</script>
<button id="b4">hide</button>
<img src="portrait.jpg" id="i3">
<script>
$(function() {
$('#b4').click(function() {
$('#i3').hide({
duration: 1000,
complete: function(){
$('#i3').show();
}
});
});
});
</script>
OpenJS Foundation (2025) .hide() | jQuery API Documentation