<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#hide").click(function(){
// hide(speed, callback) 1초뒤에
$("p").hide(1000);
});
$("#show").click(function(){
// show(speed, callback)
$("p").show(1000);
});
})
</script>
</head>
<body>
<p>If you click on the "Hide" button, I will disappear.</p>
<button id="hide">Hide</button>
<button id="show">Show</button>
</body>
</html>
jQuery hide(), show() speed 적용
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
// id가 hide 것에 대해 클릭을 하면
$("#hide").click(function(){
$("p").hide();
});
// id가 show것에 대해 클릭을 하면
// show() = > display : block 같은효과
$("#show").click(function(){
// p 태그가 나타남
$("p").show();
});
})
</script>
</head>
<body>
<p>If you click on the "Hide" button, I will disappear.</p>
<button id="hide">Hide</button>
<button id="show">Show</button>
</body>
</html>
'jQuery 수업' 카테고리의 다른 글
jQuery-6(이벤트 fadeIn(), fadeOut(), fadeTo(), fadeToggle()) (0) | 2020.02.19 |
---|---|
jQuery-5(이벤트 toggle) (0) | 2020.02.19 |
jQuery-3(마우스 이벤트, mouseenter, mouseleave, mousedown, mouseup) (0) | 2020.02.19 |
jQuery-2(더블클릭) (0) | 2020.02.19 |
jQuery -1(클릭) (0) | 2020.02.19 |