簡體   English   中英

jQuery周期-您能否定位其他頁面上的某些“幻燈片”?

[英]jquery cycle - can you target certain “slide” from other page?

因此,我嘗試在這里搜索,但發現了類似的問題,但實際上我不喜歡我可以使用的問題。因此,問題是我正在使用jquery循環插件,並且一切正常。 這就是我在頁面上使用的jQuery,比方說page.html

$(function() {
    $('#rotation').cycle({ 
        fx:'scrollRight',
        timeout: 0,
        speed: 500,
        startingSlide: 0
    });

    $('#goto1').click(function() { 
        $('#rotation').cycle(0);

        return false;
    });

    $('#goto2').click(function() { 
        $('#rotation').cycle(1); 

        return false;
    });
});

您的猜測是,我正在使用像這樣的導航來進行以下操作:

<li><a href="#" id="goto1">Link1</a></li>
<li><a href="#" id="goto2">Link2</a></li>

最后的div結構將是

<div id="rotation">
    <div> Content of first cycle </div>
    <div> Content of second cycle </div>
</div>

那很好。 現在我的問題是,我可以定位index.html的div嗎? 頁面不是php,我的想法是創建一個從索引到page.html#goto2的href,並以某種方式使用它,但是由於它不是php,所以我不知道該怎么做...如果有人知道一個把戲,我會非常感激。 謝謝。

根據您想要的選項卡將查詢字符串發送為?tab=1tab=2tab=3

現在根據QueryString值更改選項卡設置選項卡。 為簡單起見,我們將id添加到列表中的錨點,並將href動態附加到每個錨點。

    // Run this on document ready.
    var listItemsofThumbnail = $("ul.sidebarTabset li");

    listItemsofThumbnail.each(function (idx) {
        var licount = idx + 1;
        $(this).addClass("currentactive1_s" + licount)
        var linkurl = $(this).find("a").attr("href");
         $(this).find("a").attr("href", linkurl + "?tab=" + licount);
     });


    var currenturl = window.location.href;
    var QuerystringValue = getParameterByName("tab");

    switchImages(QuerystringValue);

    // document ready end.

    function switchImages(tab) {
       if (tab == null || tab == undefined || tab == 0) tab = 1; // catch any bad data
           DeactivateAllTab();
           ActivateTab(tab - 1);
       }


     // Dsiplays the li 
    function ActivateTab(i) {
         if (!($("#slider1 li#currentactive1_s" + i).hasClass("currentactive1_on"))) {
              $("#slider1 li#currentactive1_s" + i).addClass("currentactive1_on");
              $("#slider1 li#currentactive1_s" + i).css({ "float": "left", "position": "relative", "opacity": 1, "zIndex": 2, "display": "list-item" });
          }
         var thumbnailindex = i + 1;
         if (!($(".sidebarTabset li.currentactive1_s" + thumbnailindex).hasClass("active"))) {
            $(".sidebarTabset li.currentactive1_s" + thumbnailindex).addClass("active");
         }

     }

     // Hides the li
     function DeactivateAllTab() {
        $("#slider1 > li").each(function () { 
          $(this).removeClass("currentactive1_on");
          $(this).css({ "float": "none", "position": "absolute", "opacity": 0, "zIndex": 0 });
});
        $(".sidebarTabset li").each(function () {
           if ($(this).hasClass("active")) {
               $(this).removeClass("active");
            }
        });

     }

現在,我們的jquery周期是自動添加類currentactive1_on_tab name ,因此我們將其用於映射縮略圖和幻燈片。 另外,我們在activatedeactivate功能中相應地更改了css,以便像jquery循環那樣工作。

如果您有任何疑問,請告訴我。

暫無
暫無

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

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