E
E
Eugene Ch2019-01-16 21:15:19
JavaScript
Eugene Ch, 2019-01-16 21:15:19

Why does this JS code only work in Mozilla FireFox?

Can you please tell me why this "code" works correctly only in the Mozilla FireFox browser? There are no errors in the console. Thanks in advance!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
lloydbanks, 2019-01-16
@zchepygov

Old bug
doesn't work onclick on option in Chrome
Simple example:

<select>
    <option onclick="check()">one</option>
    <option onclick="check()">two</option>
    <option onclick="check()">three</option>
</select>

<script>
  function check() {
    alert('check')
  }
</script>

Solution: hang an event on select

M
Michael Lyamin, 2019-01-17
@BusteR27

As already mentioned above, it is better to never hang events on option, because the select can be styled by any plugin and it will stop working. Therefore, track the onchange of the select

D
Dmitry Gusikov, 2019-01-18
@Dicur3x

Because Firefox is the best browser.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question