Jquery说该对象不支持“每个”
Jquery saying that object doesn't support 'each'
当我运行我的 Web 应用程序时,我收到一条错误消息,指出"JavaScript 运行时错误:对象不支持属性或方法'每个'",我正在尝试在我的 jquery 滑块下方或上方创建一个图例......
这是我正在使用的脚本
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
这是我的 JQuery 脚本
$(function () {
$("#slider-range").slider({
range: true,
min: 0,
max: 100,
values: [0, 100],
animate: 'slow',
slide: function (event, ui) {
//$(ui.handle).find('span').html('$' + ui.value);
//
$("#amount").val("$" + ui.values[0] + " - $" + ui.values[1]);
}
.each(function() {
// Get the options for this slider
var opt = $(this).data().uiSlider.options;
// Get the number of possible values
var vals = opt.max - opt.min;
// Space out values
for (var i = 0; i <= vals; i++) {
var el = $('<label>'+(i+1)+'</label>').css('left',(i/vals*100)+'%');
$( "#slider" ).append(el);
}
})
});
$("#amount").val("$" + $("#slider-range").slider("values", 0) +
" - $" + $("#slider-range").slider("values", 1));
});
任何帮助将不胜感激。
谢谢
您正在对选项对象应用each
,该对象只有range
,min
,max
,values
和animate
。确实,没有each
.
您正在对幻灯片处理程序函数调用each()
- 放错了位置})
$("#slider-range").slider({
range: true,
min: 0,
max: 100,
values: [0, 100],
animate: 'slow',
slide: function (event, ui) {
//$(ui.handle).find('span').html('$' + ui.value);
//
$("#amount").val("$" + ui.values[0] + " - $" + ui.values[1]);
}// <-- you had it here
}).each(function () {
// Get the options for this slider
var opt = $(this).data().uiSlider.options;
// Get the number of possible values
var vals = opt.max - opt.min;
// Space out values
for (var i = 0; i <= vals; i++) {
var el = $('<label>' + (i + 1) + '</label>').css('left', (i / vals * 100) + '%');
$("#slider").append(el);
}
});
你在错误的地方调用.each(),你需要做}).each(function () {
$(function () {
$("#slider-range").slider({
range: true,
min: 0,
max: 100,
values: [0, 100],
animate: 'slow',
slide: function (event, ui) {
//$(ui.handle).find('span').html('$' + ui.value);
//
$("#amount").val("$" + ui.values[0] + " - $" + ui.values[1]);
}
}).each(function () { //you each loop like this
// Get the options for this slider
var opt = $(this).data().uiSlider.options;
// Get the number of possible values
var vals = opt.max - opt.min;
// Space out values
for (var i = 0; i <= vals; i++) {
var el = $('<label>' + (i + 1) + '</label>').css('left', (i / vals * 100) + '%');
$("#slider").append(el);
}
})
});
相关文章:
- 任何浏览器都不支持javascript函数
- 对象不支持属性或方法“自动完成”
- 对象没有'不支持set_viewXML
- 您的平台不支持RxJS-Array.observe
- 错误:语法错误,无法识别的表达式:不支持的伪:无效/RectJS/Unit Testing
- 使用Facebook登录,但仍然可以获得:“;此标识池不支持未经身份验证的访问“;
- 415(不支持的媒体类型)错误
- 字符串替换-不支持格式字符'}'
- CSS3卡翻转动画,检测是否不支持
- IE中不支持JQuery window.location.hash
- javascript表单字段submit:Object dos'在IE8中不支持此属性或方法
- 对象不支持对象IE 8
- 不支持Three.js FBX二进制格式
- 使用gmail-api发送电子邮件错误:此api不支持解析表单编码的输入
- 如何在不支持HTML字符的邮件正文中发送%签名
- 在粘贴到文本字段Jquery时检查并突出显示不支持的特殊字符
- 如何从 MVC4 链接调用 Javascript 方法(错误 JavaScript 运行时错误:对象不支持此操作)
- JSHint 错误“对象不支持此属性或方法”用于 javascript 闭包
- 对象不支持属性或方法“确认”
- Jquery说该对象不支持“每个”