Notice
Recent Posts
Recent Comments
Link
250x250
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- mlb stats api
- javascript
- 프로젝트
- Spring
- 스프링
- Python
- CSS
- 제이쿼리
- 자바
- 코틀린
- 자바스크립트
- 배포
- 오라클
- pandas
- MLB
- 판다스
- streamlit
- HTML
- 어플
- oracle
- 앱
- 파이썬
- gcp
- 기록
- 시간
- 안드로이드
- kotlin
- Android
- java
- JQuery
Archives
- Today
- Total
develope_kkyu
[JQUERY] 애니메이션 - 박스 옮기기 본문
728x90
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>효과 및 애니메이션</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<style>
*{
/* *은 모든 태그를 의미함. */
margin: 0;
padding: 0;
}
body{
padding: 20px;
}
.btn-wrap{
margin-bottom: 10px;
}
.wrap{
border: 1px solid black;
max-width: 600px;
}
.txt{
width: 10%;
text-align: center;
background-color: aqua;
}
</style>
<script>
$(document).ready(function(){
let txt = $(".txt"); // let txt = document.querySelector(".txt") 이와 같은 내용
let count = 1;
$(".btn-wrap button").on("click",function(){
let ts = $(this);
if(ts.hasClass("back-button")) {
// 선택되어진 Tag가 "back-button"이란 클래스를 포함하고 있으면
count--;
if(count < 1){
count = 1;
return;
}
txt.animate({marginLeft : "-=10%"}, 2000);
}
else{
count++;
if(count > 10){
count = 10;
return;
}
txt.animate({marginLeft : "+=10%"}, 2000);
}
});
});
</script>
</head>
<body>
<p class="btn-wrap">
<button class="back-button">BACK</button>
<button class="go-button">GO</button>
</p>
<div class="wrap">
<p class="txt">내용1</p>
</div>
</body>
</html>
--



728x90
'FrontEnd > JQUERY' 카테고리의 다른 글
[JQUERY] 리스트 숨기기 (0) | 2022.12.22 |
---|---|
[JQUERY] 제이쿼리 선택자 (0) | 2022.12.22 |