簡體   English   中英

IE7中未使用jQuery生成DIV

[英]DIV Not Being Generated in IE7 with jQuery

我不知道為什么該腳本無法在IE7和8中運行。它在所有其他瀏覽器中都能正常工作,但是由於某些原因,在IE7和8中,該腳本僅觸發// thumbs hover位,而不觸發// loading images位(實際上更重要)。 一切似乎都很好,有人有什么想法嗎?

     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});
            }
        );

    };

演示頁面位於http://www.weblinxinc.com/beta/welex/demo/

您的問題是由於沒有開始設置margin引起的。 然后, transitionTest變為NaN因為樣式是auto ,而不是您期望的0px 考慮改用以下方法:

var transitionTest = parseInt("0"+currentMargin,10);

這將為您修剪“ px”,並處理以margin為關鍵字的情況。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM