Javascript TypeError:value.animate不是函数
我试图为我弟弟的网站制作这个简单的小音频播放器,因为他现在的那个不太好 所以,我在HTML中有一些灰色的框,我认为如果有动画(移动以表示音乐节拍)会很好。这就是html的外观。我有一个id为reference box的div,因此我可以在jQuery中轻松找到它的同级。此外,它们有一个“h”值,表示它们将被设置动画以达到的高度。。。到目前为止,我是这样做的,但我计划在以下时间后制作rdm:Javascript TypeError:value.animate不是函数,javascript,jquery,html,Javascript,Jquery,Html,我试图为我弟弟的网站制作这个简单的小音频播放器,因为他现在的那个不太好 所以,我在HTML中有一些灰色的框,我认为如果有动画(移动以表示音乐节拍)会很好。这就是html的外观。我有一个id为reference box的div,因此我可以在jQuery中轻松找到它的同级。此外,它们有一个“h”值,表示它们将被设置动画以达到的高度。。。到目前为止,我是这样做的,但我计划在以下时间后制作rdm: <div class='greybox' id='reference-box'></di
<div class='greybox' id='reference-box'></div>
<div class='greybox' data-h='15'></div>
<div class='greybox' data-h='5'></div>
<div class='greybox' data-h='7'></div>
<div class='greybox' data-h='2'></div>
<div class='greybox' data-h='15'></div>
然后,我循环遍历一个函数中的所有元素,该函数在播放器取消暂停时调用:
function animateBars(){
if (audio.paused === false){ //Check if the audio is paused (stops if it is therefor)
$.each($boxes, function(index, value){
console.log(heightToBecome + " || " + index + " || Boxed Length: " + $boxes.length + " || Box Element: " + value);
value.animate({
height: "5px"
}, "slow");
//Do the animations (above and below)
value.animate({
height: "15px"
}, "slow", animateBars);
});
}
}
但是,我遇到了这个问题:
TypeError:value.animate不是函数。(在“value.animate”中)({
高度:“5px”
},“slow”),“value.animate”未定义)
我看过其他的帖子,但大多数我都不明白,其他的也没用
谢谢您的时间。
value
是一个domeElement,而不是jQuery对象。尝试调用元素上的jQuery方法时,请使用$(value)
$.each($boxes, function(index, value) {
var $value = $(value); // create the jQuery object...
console.log(heightToBecome + " || " + index + " || Boxed Length: " + $boxes.length + " || Box Element: " + value);
// ... then use it to perform the animations
$value.animate({
height: "5px"
}, "slow");
//Do the animations (above and below)
$value.animate({
height: "15px"
}, "slow", animateBars);
});
非常感谢你!这起作用了。我只是jQuery的初学者。。。我不知道。谢谢你的快速回复!没问题,很乐意帮忙
$.each($boxes, function(index, value) {
var $value = $(value); // create the jQuery object...
console.log(heightToBecome + " || " + index + " || Boxed Length: " + $boxes.length + " || Box Element: " + value);
// ... then use it to perform the animations
$value.animate({
height: "5px"
}, "slow");
//Do the animations (above and below)
$value.animate({
height: "15px"
}, "slow", animateBars);
});