on
제이쿼리 - 애니메이션 처럼 보이게 만들기
제이쿼리 - 애니메이션 처럼 보이게 만들기
Insert title here *{ padding: 0; margin: 0; } body { font-size:14px; font-family:"맑은 고딕", 나눔고딕, 돋움, sans-serif; } a { color: #000; text-decoration: none; } a:hover, a:active { color: tomato; text-decoration: underline; } .btn{ color:#333; font-weight:500; border:1px solid #ccc; background-color:#fff; text-align:center; cursor:pointer; padding:3px 10px 5px; border-radius:4px; } ul { list-style: none; } li{ padding: 0; } h3{ margin: 30px; } .box{ box-sizing: border-box; width: 350px; min-height: 50px; margin: 20px auto; border: 3px dotted gray; padding: 15px; } .ps { font-size: 15px; color: #fff; background: #333; padding: 5px; margin-bottom: 5px; } $(function() { // 처음, 마지막 // $("#s1 li").first().css("background", "#eee"); // $("#s1 li").last().css("background", "#eee"); // $("#s1 li").eq(0).css("background", "#eee"); // 처음 // $("#s1 li").eq(-1).css("background", "#eee"); // 마지막 // $("#s1 li").filter(":odd").css("background", "#eee"); // 홀수번째 // $("#s1 li").not(":odd").css("background", "#eee"); // 홀수 제외 $("#s1 li").has(".item").css("border", "1px solid red"); // li 요소중 클래스 item을 하위 요소로 가진 모든 li 요소 if($("label").parents().is("p")){ // 존재하면 true $(".box1").text("
show 와 hide 를 이용해서 마치 애니메이션을 넣은 것 처럼 효과를 줄 수 있다.
확인 버튼을 눌렀을때 빨간 박스가 없으면 나오게 만들고 있으면 없앤다
show(움직이는 속도) 괄호안에 속도를 줘서 움직이는 속도를 조절 할 수 있다
숫자가 작을수록 빠르고 클 수록 느리게 움직인다.
전체 코드 중 애니메이션 처럼 보이게 하는 코드 부분
$(function(){ $(".box3").css("background", "tomato"); $(".btn1").click(function(){ var isHidden = $(".box3").is(":hidden"); // var isVisible = $(".box3").is(":visible"); if(isHidden) { $(".box3").show(300); } else { $(".box3").hide(300); } }) });
from http://heidong.tistory.com/134 by ccl(A) rewrite - 2021-10-29 00:26:09