본문 바로가기

JQuery3

TOP버튼 / 누르면 맨 위로 올라가는 버튼 / scroll top / 스크롤 내리면 나타나는 버튼 $(document).ready(function () { // 1. 특정 위치에서 부터 버튼 나타고, 사라지게..효과는 fade로 $(window).scroll(function () { if ($(this).scrollTop() > 200) { $('.go-top').fadeIn(200); } else { $('.go-top').fadeOut(200); } }); // 2. 버튼 클릭하면 원하는 위치로 이동 $('.go-top').click(function (event) { event.preventDefault(); $('html, body').animate({ scrollTop: 0 }, 300); }); }); [1] 스크롤이 200보다 크다면 .go-top버튼을 fadeIn하고, 아니라면 fadeO.. 2020. 7. 28.
[jQuery] if, else if, else 사용법 if A1을 만족하면 description1 실행 if ('A1') { description1 } if, else A1을 만족하면 description1 실행, 아니라면 description2 실행 if('A1') { description1 } else { description2 } if, else if, else A1을 만족하면 description1 실행, A2을 만족하면 description2 실행, 둘 다 만족하지 못하면 description3을 실행 if('A1') { description1 } else if('A2') { description2 } else { description3 } [예제] if, else ex) div에 B가 있다면 C에 C0를 추가하고 없다면 C1를 추가합니다. $(d.. 2020. 7. 8.
[Jquery] 경고창 띄우기 [마크업] 눌러주세요 [제이쿼리] [★ajax★] ※ 제이쿼리와 ajax는 사이에 넣어주세요. 반드시 ajax 먼저 넣고 제이쿼리 작성해주세요. 그렇지 않으면 잘짜여진 제이쿼리도 작동하지 않습니다. [결과물] 2019. 9. 4.
반응형