admin管理员组文章数量:1320608
<div class="table-thing with-label widget uib_w_114 d-margins" data-uib="app_framework/flip_switch" data-ver="1">
<label class="narrow-control label-inline">Notifications</label>
<div class="wide-control">
<input type="checkbox" class="toggle" id="af-flipswitch-1" name="af-flipswitch-1" checked="checked">
<label for="af-flipswitch-1" data-off="Off" data-on="On">
<span></span>
</label>
</div>
</div>
I am not sure how to get the value from the flip switch (On or Off) and assign to a javascript variable.
Edit: The above code is from App Designer (Intel XDK)
To get the value use,
if ($('#af-flipswitch-1').is(":checked"))
{
console.log("On");
} else {
console.log("Off");
}
<div class="table-thing with-label widget uib_w_114 d-margins" data-uib="app_framework/flip_switch" data-ver="1">
<label class="narrow-control label-inline">Notifications</label>
<div class="wide-control">
<input type="checkbox" class="toggle" id="af-flipswitch-1" name="af-flipswitch-1" checked="checked">
<label for="af-flipswitch-1" data-off="Off" data-on="On">
<span></span>
</label>
</div>
</div>
I am not sure how to get the value from the flip switch (On or Off) and assign to a javascript variable.
Edit: The above code is from App Designer (Intel XDK)
To get the value use,
if ($('#af-flipswitch-1').is(":checked"))
{
console.log("On");
} else {
console.log("Off");
}
Share
Improve this question
edited Feb 11, 2015 at 11:44
Vijay Rajasekaran
asked Feb 11, 2015 at 10:11
Vijay RajasekaranVijay Rajasekaran
6131 gold badge9 silver badges18 bronze badges
1 Answer
Reset to default 3flip switch html code
<label for="flip-1">Flip switch:</label>
<select name="flip-1" id="flip-1" data-role="slider">
<option value="off">Off</option>
<option value="on">On</option>
</select>
<button id="submit">Submit</button>
Jquery code
$(document).delegate("#submit", "tap", function() {
alert($("#flip-1").val());
});
Click to Demo
本文标签: javascriptHow to get selected value from a Flip Switch or Toggle SwitchStack Overflow
版权声明:本文标题:javascript - How to get selected value from a Flip Switch or Toggle Switch - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742079560a2419615.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论