Javascript 未使用jQuery在IE7中生成DIV
我不明白为什么这个脚本在IE7和IE8中不起作用。它在所有其他浏览器中都可以正常工作,但出于某种原因,在IE7和IE8中,该脚本只触发Javascript 未使用jQuery在IE7中生成DIV,javascript,jquery,html,css,internet-explorer,Javascript,Jquery,Html,Css,Internet Explorer,我不明白为什么这个脚本在IE7和IE8中不起作用。它在所有其他浏览器中都可以正常工作,但出于某种原因,在IE7和IE8中,该脚本只触发//拇指悬停位,而不是//加载图像位(这实际上更重要)。一切似乎都很好,有人有什么想法吗 function featuredJS() { $("[title]").attr("title", function(i, title) { $(this).data("title", title).removeAttr(
//拇指悬停
位,而不是//加载图像
位(这实际上更重要)。一切似乎都很好,有人有什么想法吗
function featuredJS() {
$("[title]").attr("title", function(i, title) {
$(this).data("title", title).removeAttr("title");
});
// loading images
var last = "featured/01.jpg";
$("#thumbs a").click(function(event) {
event.preventDefault();
var position = $(this).attr("class");
var graphic = $(this).attr("href");
var title = $(this).attr("alt");
var description = $(this).data("title");
var currentMargin = $("#full-wrapper #full").css("marginLeft");
var currentWidth = $("#full-wrapper #full").css("width");
var transitionTest = currentMargin.replace("px", "") * 1;
if(last != graphic && ((transitionTest % 938) == 0 || transitionTest == 0)) {
$("#placeholder").before( "<div class='featured'><div class='description " + position + "'>" + "<h3>" + title + "</h3>" + "<p>" + description + "</p>" + "</div><img src=\"" + graphic + "\" /><div style='clear:both;'></div></div>" );
$("#full-wrapper #full").animate({
marginLeft: "-=938px"
}, 500);
$("#full-wrapper #full").css("width","+=938px");
last = graphic;
};
});
// thumbs hover
$("#thumbs .thumb").hover(
function () {
$(this).find(".red-bar").animate({height:"72px"},{queue:false,duration:500});
},
function () {
$(this).find(".red-bar").animate({height:"3px"},{queue:false,duration:500});
}
);
};
函数特性djs(){
$(“[title]”).attr(“title”,函数(i,title){
$(this).data(“title”,title).removeAttr(“title”);
});
//加载图像
var last=“featured/01.jpg”;
$(“#拇指a”)。单击(函数(事件){
event.preventDefault();
var position=$(this.attr(“类”);
var graphic=$(this.attr(“href”);
var title=$(this.attr(“alt”);
变量说明=$(此).data(“标题”);
var currentMargin=$(“#完整包装#完整”).css(“marginLeft”);
var currentWidth=$(“#完整包装器#完整”).css(“宽度”);
var transitionTest=currentMargin.replace(“px”,即“)*1;
如果(最后一个!=图形&((传递测试%938)==0 | |传递测试==0)){
$(“#占位符”)。在(“+”+标题+“+”“+说明+”“+”)之前;
$(“#完整包装#完整”)。动画({
边缘左侧:“-=938px”
}, 500);
$(“#完整包装#完整”).css(“宽度”,“+=938px”);
最后=图形;
};
});
//拇指悬停
$(“#thumbs.thumb”)。悬停(
函数(){
$(this.find(“.red bar”).animate({height:“72px”},{queue:false,duration:500});
},
函数(){
$(this.find(“.red bar”).animate({height:3px},{queue:false,duration:500});
}
);
};
演示页面中的您的问题是由于没有设置
页边距而导致的transitionTest
然后变为NaN
,因为样式是auto
,而不是您所期望的0px
。考虑一下这个问题:
var transitionTest = parseInt("0"+currentMargin,10);
这将为您删除“px”,并处理边距是关键字的情况