때때로 event
객체가 javascript에 필요하다는 것을 알 수 있습니다.
다음은 몇 가지 코드입니다. event
을 전달하는 방법은 무엇입니까? 당신이 기능에 이벤트를 전달하려면자바 스크립트 함수에서 이벤트 객체 전달
function test(e){
console.log(e);
e.preventDefault();
console.log("you are not going to redirect");
}
HTML
<a href="www.google.com" onclick="test(event)">GOOGLE</a>
그냥 함수 인수에 event
를 전달합니다.
[이벤트 객체를 매개 변수로 전달하지 않고 이벤트 처리 함수에서 이벤트 객체를 가져올 수 있습니까? (jquery와 함께)] (http://stackoverflow.com/questions/5849370/get-the-event-object-in-an-event-handling-function-without-pass-the-event-object) –
싶어요 'e.preventDefault()'를 사용하면 업데이트 질문 –
이 정확한 코드 semms를 볼 수 있습니다. prooblem은 코드가 사용자의 함수와 함께 사용되는 코드를 표시하지 않는다는 것입니다. – youssouf