How does Zurb Foundation Switch control work -


i started using zurb foundation 4 asp mvc website , don't quite understand how switch control supposed work. docs don't http://foundation.zurb.com/docs/components/switch.html

<div class="switch">   <input id="x" name="switch-x" type="radio" checked>   <label for="x" onclick="">off</label>    <input id="x1" name="switch-x" type="radio">   <label for="x1" onclick="">on</label>    <span></span> </div> 

i'm using example code, when click on switch, there no change in html. figured "checked" attribute go on second input, not case.

  • how can detect radio button has been clicked ?

when post form, "switch-x" variable contains value "on" no matter position switch in.

i tried adding onclick event on label, it's not getting fired seems overlapping label.

i'm using foundation's javascript, don't have errors on page.

i'm missing something... ideas ?

how can detect radio button has been clicked ?

you have id each of radio inputs can use them:

$('input[name=switch-x]:checked').attr('id'); 

that give either x or x1. depends on how use it. if passing boolean value, think would, can a:

var ison = $('input[name=switch-x]:checked').attr('id') == 'x1'; 

or simply

var ison = $('#x1').is(':checked'); 

see in action here


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -