0

Currently I have this html:

<div id="forMouseEvents"

    onmouseover=""
    onclick=""
    oncontextmenu=""
    ondblclick="" 
    onmousemove=""
    onmousedown=""
    onmouseup=""
    onmouseleave=""
    >

</div>

I will add later the functions I would like to call on the relative event. Is it better to do something like this? Why? Is there any difference?

$( "#forMouseEvents" ).click(function() {
    // code
});
$( "#forMouseEvents" ).whatever(function() {
    // code
});
...
devamat
  • 2,293
  • 6
  • 27
  • 50
  • Possible duplicate of [Why is inline event handler attributes a bad idea in modern semantic HTML?](https://stackoverflow.com/questions/11737873/why-is-inline-event-handler-attributes-a-bad-idea-in-modern-semantic-html) – Obsidian Age Feb 21 '18 at 03:43
  • Possible duplicate of [addEventListener vs onclick](https://stackoverflow.com/questions/6348494/addeventlistener-vs-onclick) – Randy Casburn Feb 21 '18 at 03:45
  • Find your answer [**Here**](https://stackoverflow.com/questions/6348494/addeventlistener-vs-onclick?noredirect=1&lq=1#answer-6348597) – theAlexandrian Feb 21 '18 at 03:53

0 Answers0