1

I know that i can do

<element onclick(function(event))></element>

but how can i pass event to fuction using just code

document.getElementById('elementId').onclick = function(){event.preventDefault()}
1
  • 1
    It would be better to use EventTarget.addEventListener. Otherwise, @victor has given you the answer. Commented Apr 19, 2017 at 17:46

1 Answer 1

6

Put it as a parameter in your on click handler

document.getElementById('elementId').onclick = function(event){    
event.preventDefault()    
}
Sign up to request clarification or add additional context in comments.

2 Comments

@AidOnline01 if this solves your problem, could you please mark it as an answer?
of course, it's just prohibited mark it as answer instantly, and i forgotten)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.