dimanche 29 janvier 2017

Why do checkboxes have setSelectionRange property and how to test for it?

I am pretty sure I used to test check boxes for the setSelectionRange property and they did not have one. But that seems to have changed in some browsers (tested Firefox and Chrome).

I used to do a check for the setSelectionRange property before making a selection like this:

if (el.setSelectionRange) {
  el.setSelectionRange(0, 9999);
}

However, since check boxes appear to have the setSelectionRange property this throws an error.

So how do I test now for whether a selection can be made or not?

Here is also a fiddle:

http://ift.tt/2jK27a0




Aucun commentaire:

Enregistrer un commentaire