好吧,所以我是jquery的新手。如何從其他頁面加載圖庫到我的頁面上的div?
我想要做的是在一個頁面中有多個畫廊。 在另一頁我有一個div和一些鏈接。取決於你在哪個鏈接點擊畫廊要顯示在div應該改變。
我的所有鏈接都有不同的ID和我的所有畫廊。
我知道應該有一種方法可以使用Jquery。任何人都可以告訴我如何做到這一點。
謝謝:)
好吧,所以我是jquery的新手。如何從其他頁面加載圖庫到我的頁面上的div?
我想要做的是在一個頁面中有多個畫廊。 在另一頁我有一個div和一些鏈接。取決於你在哪個鏈接點擊畫廊要顯示在div應該改變。
我的所有鏈接都有不同的ID和我的所有畫廊。
我知道應該有一種方法可以使用Jquery。任何人都可以告訴我如何做到這一點。
謝謝:)
你可以爲每個畫廊做標籤,以及庫內容是通過AJAX加載。我會建議您檢查出:http://jqueryui.com/demos/tabs/#ajax
假設每個環節點的href感興趣的畫廊,你可以這樣做以下:
$(document).ready(function() {
// bind to the click event of each link with class 'gallery'
$("a.gallery").click(function() {
// load the HTML at the href of the clicked link into a div
$("#galleryDiv").load($(this).attr("href"));
});
});
如果你只是想在一個部分加載從我websi
// only fetch <div id="galleryDiv"> from target page
$("#galleryDiv").load($(this).attr("href") + " #galleryDiv");
當我的用戶點擊購買按鈕,希望另一頁:目標頁面,只需適當選擇加入的load
的URL參數,例如:使用它們選擇的產品圖像加載到purchase.html的div上。 (第一頁HTML)
<td width="203"><img src="images/chocoImage4.png" width="190" height="206" class="birthpic1"/> Hershey's Bouquet Mix $32</td>
<td width="211"><img src="images/chocoImage5.png" width="190" height="206" class="birthpic2"/>Chocolate Strawberry $52</td>
<td width="203"><img src="images/chocoImage6.png" width="190" height="200" class="birthpic3"/>Chocolate Strawberry $42</td>
(第二頁面的html purchase.html)
<div class="aside">
<div class="hours"><!-- TemplateBeginEditable name="hours" -->
<p><strong>North Las Vegas</strong> Coming Soon!!!<br />
<strong>Monday-Friday:</strong> 9:00 am — 5:00 pm<br />
<strong>Saturday: </strong>8:00am — 2:00 pm</p>
<!-- TemplateEndEditable --></div>
<div id="imagePicked">
<p>Hello</p>
</div>
的JavaScript(代碼)
function load_Product() {
var theDomain = window.location.assign("purchase1.html");
var d = document.getElementById("imagePicked");
var p = d.childNodes[0];
var imageContent = p.innterHTML;
var productImage = '<img src="http://flowersbyreginalv.com/chocoImage1.png">';
imageContent = productImage;
loadSum = imageContent + theDomain;
}