我想在下面的代码中将滑块的值存储在警告消息中,其中我有占位符alert('stop')
<head>
<title>Page 1</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" media="all" href="css/style.css" />
<link rel="stylesheet" type="text/css" media="all" href="css/ui.css" />
<link rel="stylesheet" type="text/css" media="all" href="css/jquery.mobile.structure-1.2.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function () {
//depending on the device we have a touch or a mouse event
var supportTouch = jQuery.support.touch,
touchStartEvent = supportTouch ? "touchstart" : "mousedown",
touchStopEvent = supportTouch ? "touchend" : "mouseup",
touchMoveEvent = supportTouch ? "touchmove" : "mousemove";
//the event is binded to the .ui-slider inside of the input type range
jQuery('#msBig').siblings('.ui-slider').bind(touchStopEvent,function() {
alert('stop')
});
});
</script>
</head>
<body>
<div id="page1" data-role="page">
<div data-role="header">
<h1>Page Title</h1>
</div><!-- /header -->
<div data-role="content">
<input type="range" id="msBig" value="50" tabindex="0" data-theme="b" max="100" min="0" size="3" />
</div><!-- /content -->
<div data-role="footer">
<h4>Page Footer</h4>
</div><!-- /footer -->
</div><!-- /page -->
</body>
</html>
我在以下网站找到了代码: https://forum.jquery.com/topic/how-to-execute-javascript-code-when-finger-is-lifted-from-a-slider
我尝试过各种各样的解决方案但空手而归。
var selection = $(".selector").slider("value");
在jQuery API中,但我不知道如何在上面的代码中实现它。