how to add preventdefault in html onclick event code example Example: js preventdefault function(event) { event.preventDefault(); }