Getting value from toggle switch in jQuery Mobile
html, javascript, jquery, jquery-mobile
Solution
Just 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.net/2ckHr/9/
$(document).delegate("#submit", "vclick", function() {
alert($("#flip-1").val());
});
Problem
Super basic question, but I can't figure out why the following code won't work: http://jsfiddle.net/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.