Materialize: Switch-styled checkboxes do not have 'value' or 'checked' attributes

Created on 29 Jul 2015  路  2Comments  路  Source: Dogfalo/materialize

Documentation does not explain how do I use them either. I mean, they look really fancy. But how do I actually use them in my app? Where do I read the attribute if the switch is switched or not? If it is there and I just cannot see it, documentation (website demo) should explain it.

Thank you for your work and have a good day!

Most helpful comment

It's just a normal checkbox: http://codepen.io/anon/pen/eNQMOL

All 2 comments

It's just a normal checkbox: http://codepen.io/anon/pen/eNQMOL

Came up with something that might help:

//Set Function To Check Element has color applied for being toggled on
function is_toggled(){
if ($('.switch label input[type=checkbox]:checked + .lever').css('color')) {
//Perform Action as it is toggled on
} else {
//Perform action when toggled off
}
}

//Set listener
$(document).on({
'mouseup':function (e) {if (e.which == 1) {is_toggled()}},
'keyup':function (e) {if (e.which == 32) {is_toggled()}}
}, '#Toggle_Div');

Was this page helpful?
0 / 5 - 0 ratings

Related issues

samybob1 picture samybob1  路  3Comments

SoproniOli713 picture SoproniOli713  路  3Comments

Robouste picture Robouste  路  3Comments

ReiiYuki picture ReiiYuki  路  3Comments

hartwork picture hartwork  路  3Comments