alerts ons-switch giving undefined
-
Every time when i click the button i am getting checked as undefined…
<ons-list modifier="inset" class="settings-list"> <ons-list-item > <span class="trn" data-trn-key="enabled_push_notification">Restaurant ON/OFF</span> <ons-switch var="s" modifier="list-item" onclick ="checking();" ></ons-switch> </ons-list-item> </ons-list>
My javascript function
function checking(){ alert("checking........+1"+document.getElementById("s").checked); }
-
That’s probably because you have
var="s"
instead ofid="s"
. But there should have been an error in the console first, right?