admin管理员组文章数量:1328798
Super basic question, but I can't figure out why the following code won't work:
/
HTML
<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>
JS
$(document).delegate("#submit", "tap", function() {
alert($("#flip-1").val());
});
Returns Uncaught TypeError: Cannot call method 'call' of undefined (jquery.mobile-1.3.0-beta.1.js:2823)
when submit is pressed.
Super basic question, but I can't figure out why the following code won't work:
http://jsfiddle/2ckHr/3/
HTML
<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>
JS
$(document).delegate("#submit", "tap", function() {
alert($("#flip-1").val());
});
Returns Uncaught TypeError: Cannot call method 'call' of undefined (jquery.mobile-1.3.0-beta.1.js:2823)
when submit is pressed.
-
Changing
tap
toclick
makes it work for me. Is there a difference between the two in jQuery Mobile? – ayyp Commented Jul 12, 2013 at 18:51
2 Answers
Reset to default 3Just use vclick
instead of tap
or click
. It is a jQuery Mobile event that bridges a mobile and desktop problems with tap/click not working on both platforms.
Working example: http://jsfiddle/2ckHr/9/
$(document).delegate("#submit", "vclick", function() {
alert($("#flip-1").val());
});
$('#submit').on("click", function() {
alert($("#flip-1").val());
});
本文标签: javascriptGetting value from toggle switch in jQuery MobileStack Overflow
版权声明:本文标题:javascript - Getting value from toggle switch in jQuery Mobile - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742222627a2435549.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论