我不断收到错误TurnJsError:此选择器有超过 1 个元素 我在 Firebug 中进行了一些检查,我知道我的 Jquery 正在加载,我需要的所有库/脚本也是如此。
错误出现在我的页面加载后,如果我将 javascript 的以下部分添加到控制台并在页面完全加载之前运行它,那么它可以,但仍然返回与上面相同的错误,但是如果我让页面加载(再次从上面得到错误),然后在控制台中运行该脚本,我收到另一个错误 TypeError: Argument 1 of Node.insertBefore does not Implement Interface Node.:
function loadApp() {
// Create the flipbook
$('.flipbook').turn({
// Width
width:922,
// Height
height:600,
// Elevation
elevation: 50,
// Enable gradients
gradients: true,
// Auto center this flipbook
autoCenter: true
});
}
// Load the HTML4 version if there's not CSS transform
$(document).ready(function() {
yepnope({
test : Modernizr.csstransforms,
yep: ['../../lib/turn.js'],
nope: ['../../lib/turn.html4.min.js'],
both: ['css/basic.css'],
complete: loadApp
});
});
我是否遗漏了一些导致抛出这些错误的东西?
当我添加 .first() 时,它就像 $('.flipbook').first().turn({ 页面完全加载后,我的图像出现轻微的移动,但仍然收到错误 TypeError:Node.insertBefore 的参数 1 未实现 Node 接口(interface)。 当我单击图像时,它消失了,但下一个图像没有显示,而是出现另一个错误 TypeError: c is null
最佳答案
turn.js 使用单个元素。使用 .each 函数。
$('.flipbook').each(function(){
$(this).turn(...);
})
请注意,回合可能需要容器上的唯一 ID。
关于javascript - 该选择器有超过 1 个元素错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21336266/