-
211007_animate,z-indexJQuery 2021. 10. 8. 10:08
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
<style type="text/css">
div.wall {
position: absolute;
width: 200px;
height: 500px;
background-image: url("../image/bg2.png");
z-index: 2;
}
#img1{
position: absolute;
left: 140px;
top: 100px;
width: 150px;
height: 200px;
z-index: 1;
}
</style>
<script type="text/javascript">
$(function () {
$("#img1").click(function() {
//3번째 함수는 너비가 0되면 호출되는 함수
$(this).animate({width: "0px"},'slow',function(){
$(this).animate({width: "150px"}, 'slow');
});
});
//trigger이용하여 3초에 한번씩 클릭 효과
setInterval(function() {
$("#img1").trigger("click");
}, 3000);
});
</script>
</head>
<body>
<div class="wall"></div>
<img alt="" src="../image/03.png" id="img1">
</body>
</html>
'JQuery' 카테고리의 다른 글
211007_table,click,addClass,removeClass (0) 2021.10.08 211007_array,animate,image,mouseover (0) 2021.10.08 211007_animate,active,image (0) 2021.10.08 211007_div,z-index (0) 2021.10.07 211007_trigger (0) 2021.10.07