I have an HTML button like so:
<div class="row text-center">
<button id="button1" type="submit" class="btn btn-primary">Submit</button>
</div>
I'd like to add an onclick behavior for it via Javascript. It should call another function. I have tried this:
$("#button1").addEventListener("click", showAlert());
However, the browser is complaining that $(...).addEventListener is not a function. What should I do instead?
addEventListenerworks on DOM objects. jQuery wraps up the DOM into its own array and has its own methods for doing things. Better to stick with one or the other, mixing and matching gets confusing -- fast.