jQuery calling click multiple times

Viewed 85

Calling click on an element here via jQuery actually calls it 3 times

This only happens in the latest version of jQuery

$("#a").click()
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<div>
  <input type="radio" id="a" name="type" checked="checked" value="guest" onclick="alert('a')" />
  <label>A</label>
</div>
<div>
  <input type="radio" name="type" value="guest" onclick="alert('b')" />
  <label>B</label>
</div>

http://jsfiddle.net/2ra0h9ns/3/

1 Answers

Response from jQuery.

"In general, inline event handlers are incredibly hard to work with and should not be used. In nearly all cases, issues involving inline event handlers are out of scope. Inline handlers do not behave the same way as event handlers added with the standard DOM addEventListener method."

https://github.com/jquery/jquery/wiki/Won't-Fix#inline-event-handlers

Related