function(e) 속에 e.preventDefault(); 사용
a링크를 클릭했을 때, 주소창에 #붙으며 스크롤 올라가는 것을 방지하는 이벤트.
기존 이벤트를 죽인다고 생각하면 됨.
$(function(){
$("#e120504 #stamp .btn").click(function(e){
$("."+$(this).attr("name")).fadeIn(700);
var num_1 = $("#e120504 #stamp .num_1").text();
if(num_1 > 0){
num_1--;
$("#e120504 #stamp .num_1").text(num_1);
}
e.preventDefault();
});
$("#e120504 #stamp .btn_ch").click(function(e){
$("."+$(this).attr("name")).fadeIn(700);
var num_2 = $("#e120504 #stamp .num_2").text();
if(num_2 > 0){
num_2--;
$("#e120504 #stamp .num_2").text(num_2);
}
e.preventDefault();
});
$("#e120504 .tab area").click(function(e){
$("#e120504 .tab p img").attr("src","http://bimage.interpark.com/bookpark/2012/event/201205/120504/"+ $(this).attr("name") +".gif");
e.preventDefault();
});
});
JQuery Plugin 플러그인 (0) | 2022.12.02 |
---|---|
Node 노드 (0) | 2022.12.01 |
Jquery 요소 / this $(this) 차이 (0) | 2022.12.01 |
JQuery 아이디에 아이디 상속 불가. (0) | 2022.11.25 |
input radio 사용법 데이터 가져오고 바꿔주기 (0) | 2022.11.25 |