16

I'm using the Materialize library and I'm trying to retrieve the value from the switches component, but it always returns on regardless of it being turned on or off.

Is there a way to determine if it's switched on or off, programatically?

Dylan Valade
  • 5,565
  • 6
  • 42
  • 56
Tomas Romero
  • 8,418
  • 11
  • 50
  • 72

1 Answers1

49

You have to use .checked For example: Javascript:

document.getElementById('mySwitch').checked

JQuery:

$('#mySwitch').prop('checked')

I hope that I help you.