2011-01-29 4 views
2

안녕하세요. 앵커 태그가 있지만 jquery를 사용하여 기본 동작을 방지하고 싶습니다. 그러나 정확한 해결책을 얻는 것은 아닙니다. 내 코드에서 무엇이 잘못되었는지 말해 줄 수 있습니까?jquery를 사용하여 기본 동작을 방지합니다.

 
$(document).ready(function(){ 
    $("a[name]").click(function(event){ 
    alert("As you can see, the link no longer took you to jquery.com"); 
    eventpreventDefault(); 
    }); 
}); 

답변

4

당신은 점을 누락 :

eventpreventDefault(); 

은 다음과 같아야합니다

event.preventDefault(); 
당신이 (특정 링크에가는) 기본 동작을 해제하고자하는 경우

또한 return false을 사용할 수 있습니다로 이벤트 버블 링 :

$(document).ready(function(){ 
    $("a[name]").click(function(event){ 
    alert("As you can see, the link no longer took you to jquery.com"); 
    return false; 
    }); 
}); 
+0

미안, 어리석은 엄마. 고마워. 고마워. – newdeveloper

관련 문제