javascript – Jquery移动滑块更改事件
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了javascript – Jquery移动滑块更改事件,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2801字,纯文字阅读大概需要5分钟。
内容图文
![javascript – Jquery移动滑块更改事件](/upload/InfoBanner/zyjiaocheng/699/5c9b91b28a5045709313015b97ee538e.jpg)
我在一个简单的页面上有一个jquery移动滑块.拖动滑块时,值会在文本框中按预期更新.我看了,但无法找到这种逻辑发生的地方.
我想要的是将值传递给javascript函数.如何将change事件绑定到我的函数?
干杯
麦克风.
下面的代码 – 请忽略一些讨厌的黑客:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>jQuery Mobile Docs - Forms</title>
<link rel="stylesheet" href="fader/jquery.mobile-1.0a3.css" />
<script type="text/javascript" src="fader/jquery-1.5.js"></script>
<script type="text/javascript" src="fader/jquery.mobile-1.0a3.js"></script>
<script>
$('#slider-1').changed(function () {
alert("Test");
});
</script>
<style type="text/css">
.toolbar {
-webkit-box-sizing: border-box;
border-bottom: 1px solid #000;
padding: 10px;
height: 45px;
background: url(fader/Resources/Themes/JQT/img/toolbar.png) #000000 repeat-x;
position: relative;
}
.toolbar > h1 {
position: absolute;
overflow: hidden;
left: 50%;
top: 10px;
line-height: 1em;
margin: 1px 0 0 -75px;
height: 40px;
font-size: 20px;
width: 150px;
font-weight: bold;
text-shadow: rgba(0, 0, 0, 1) 0 -1px 1px;
text-align: center;
text-overflow: ellipsis;
white-space: nowrap;
color: #fff;
}
.button, .back, .cancel, .add {
position: absolute;
overflow: hidden;
top: 8px;
right: 10px;
margin: 0;
border-width: 0 5px;
padding: 0 3px;
width: auto;
height: 30px;
line-height: 30px;
font-family: inherit;
font-size: 12px;
font-weight: bold;
color: #fff;
text-shadow: rgba(0, 0, 0, 0.5) 0px -1px 0;
text-overflow: ellipsis;
text-decoration: none;
white-space: nowrap;
background: none;
-webkit-border-image: url(fader/Resources/Themes/JQT/img/button.png) 0 5 0 5;
}
body > * {
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#1e1f21), to(#272729));
}
.back {
left: 6px;
right: auto;
padding: 0;
max-width: 55px;
border-width: 0 8px 0 14px;
-webkit-border-image: url(fader/Resources/Themes/JQT/img/back_button.png) 0 8 0 14;
}
.back.active {
-webkit-border-image: url(Fader%20Test%20-%20Trade%20show/img/back_button_clicked.png) 0 8 0 14;
color: #aaa;
}
h1, h2 {
font: bold 18px Helvetica;
text-shadow: rgba(255, 255, 255, .2) 0 1px 1px;
color: #FFF;
margin: 10px 20px 5px;
}
body {
background: #000;
color: #ddd;
}
</style>
</head>
<body>
<div class="ui-body-a" data-role="page">
<div class="toolbar">
<h1>Input</h1>
<A class="back" HREF="javascript:javascript:history.go(-1)">Home</A
></div>
<form action="#" method="get">
<div class="ui-body-a" data-role="fieldcontain">
<h1>Lighting Intensity</h1>
<input type="range" name="slider-1" id="slider-1" value="0" min="0" max="100" data-theme="b" data-track-theme="a" orientation="vertical" />
</div>
</form>
</div><!-- /content -->
</div><!-- /page -->
</body>
</html>
解决方法:
迈克尔.尝试用另一个元素包围滑块:
<div id="div-slider">
<input type="range" id="slider-1" />
</div>
你可以在变化中获得一个事件:
$("#div-slider").change(function() {
var slider_value = $("#slider-1").val();
// do something..
});
内容总结
以上是互联网集市为您收集整理的javascript – Jquery移动滑块更改事件全部内容,希望文章能够帮你解决javascript – Jquery移动滑块更改事件所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。