我在萤火虫控制台中收到此错误,无法找出原因。我的代码如下:
$(document).ready(function(){
var header = $('h2#chase');
var headerOffset = header.offset();
header.css({
"position" : "absolute",
"left" : headerOffset.left+"px",
"top" : headerOffset.top+"px"
});
var headerSize = {width: header.width(), height: header.height()};
var headerBounds = {top: headerOffset.top, right: headerOffset.left + headerSize.width, bottom: headerOffset.top + headerSize.bottom, left: headerOffset.left};
var windowBounds = {top: 0, right: $(window).width() - headerSize.width, bottom: $(window).height() - headerSize.height, left: 0};
var maxLeft = $(window).width() - headerSize.width;
var maxTop = $(window).height() - headerSize.height;
var margin = 30;
$(window).mousemove(function(e){
headerOffset = header.offset();
headerBounds = {top: headerOffset.top, right: headerOffset.left + headerSize.width, bottom: headerOffset.top + headerSize.height, left: headerOffset.left};
var sides = whichSides(e.pageX, e.pageY);
$.each(sides, function(key, value) {
header.css({
value.side : value.newValue+"px"
})
});
});
function whichSides(mouseX, mouseY) {
var sides = [];
var sideOffsets = {top: headerBounds.top - mouseY, right: mouseX - headerBounds.right, bottom: mouseY - headerBounds.bottom, left: headerBounds.left - mouseX};
var newValues = {top: mouseY + margin, right: mouseX - margin, bottom: mouseY - margin, left: mouseX + margin};
$.each(sideOffsets, function(key, value) {
if (value < 30 && value >= 0) {
sides.push({side: key, newValue: newValues[key]});
}
});
return sides;
}
});
错误萤火虫正在返回:
missing : after property id (line 24, col 9)
value.side : value.newValue+"px"
编辑:抱歉,我似乎从今天早上早些时候写的草稿中发布了代码,我已经用真正错误的代码更新了它。