使用翻转切换开关,当toogle“关闭”或“打开”时,我没有收到警报消息 在 jquery mobile 中请帮帮我
在 html5 中
<select name="toggleswitch1" id="toggleswitch1" data-theme="" data-role="slider">
<option value="off">Off</option>
<option value="on">On</option>
</select>
在脚本中
$(document).bind("pageinit", function () {
$("#toggleswitch1").unbind('change').bind('change', function() {
if ($("#toggleswitch1").val('off').slider('refresh')) {
alert("off");
}
else {
alert("on");
}
});
});
最佳答案
工作示例:http://jsfiddle.net/39DEK/
$(document).on('pageinit', '#index', function(){
$(document).off('slidestop',"#toggleswitch1").on('slidestop', "#toggleswitch1" ,function() {
if ($("#toggleswitch1 option:selected").val() == 'off') {
alert("off");
} else {
alert("on");
}
});
});
关于html - 使用翻转切换开关,当切换为 "off"或 "on"时,我没有收到警报消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17587106/