example4의 "Google"링크를 클릭하면 2 개의 경고 메시지가 표시됩니다. [alert3 메시지도 표시됩니다.] this.i에 대한 해결책을 제공하십시오. example4의 링크를 차별화하려고했지만 결과가 없습니다. 2 개의 경고 메시지가 나타납니다.jquery에서 링크를 구분하는 방법은 무엇입니까?
이 코드가 잘못된 것입니다. 저는 Jquery world에서 초보자입니다.
jQuery 코드 :
//Example 03 - Prevent Default Action of HTML Element
$(document).ready(function(){
$("a").click(function(e){
e.preventDefault();
alert("Example 3 :: The default action of anchor element has been prevented using Jquery");
});
});
//Example 04 - Is Default Action Prevented of HTML Element
$(document).ready(function(){
$("a.checkaction").click(function(event){
event.preventDefault();
alert("Example4 :: Is default action prevented of anchor <a>element :: "+event.isDefaultPrevented());
});
});
HTML 코드 :
<!-- Jquery example 03 - Prevent default behavior of HTML element using Jquery -->
<h1 class="header">Example 3 - Prevent default behavior of HTML Element</h1>
<a href="http://www.facebook.com">Facebook</a>
<!-- Jquery example 04 - How to check whether the default action oh html is prevented or not using jquery -->
<h1 class="header">Example 4 - How to check whether the default action oh html is prevented or not</h1>
<a href="http://www.google.com" class="checkaction">Google</a>
이 코드는 잘 작동합니다. "false를 반환"한다는 것은 무슨 뜻입니까? – Arjunan
이 인스턴스에서'return false; '는 요소의 기본 동작을 금지합니다. 양식과 jQuery를 다룰 때 주로 사용됩니다. 동일한 것은'preventDefault()'는 본질적으로 -하지만 코드는 적다. –
감사합니다. Mike Barwick. – Arjunan