0
我試圖加載一個HTML文件使用jquery加載()到<section>
隱藏在可見屏幕的右側。該函數獲取我請求的文件(如螢火蟲中所示)的正確部分,觸發回調動畫(如屏幕上所示),但不填充<section>
。加載()點擊不填充<section>
當我console.log()匹配的元素,它看起來好像它應該填充正確的部分。幫幫我?
我的jQuery看起來是這樣的:
$("a.more").not('.contact').click(function (event){
event.preventDefault();
var target = $(this).attr('href')+' #content';
$(this).parents('article').children('section.toPopulate').load(target, function() {
$(this).parents('article').children('header').animate({
'left' : -$(this).parent('article').children('header').outerWidth()
});
$(this).animate({
'left' : 0
});
});
});
的HTML看起來像這樣(和有更多的這些下跌的一頁)
<article id="projectID" class="project">
<header class="dark">
<div class="intro">
<figure class="logo">
<img ..>
</figure>
<h1>...</h1>
<div class="text">
<p>...</p>
</div>
<a class="more" href="#">more</a>
</div>
</header>
<section class="slide toPopulate">
</section>
</article>
謝謝!
'target'是否來自同一臺服務器? – Cheery 2012-03-07 06:33:57
成功之後肯定會出現奇怪的症狀,並且可以在控制檯中看到htm ....嘗試更改爲$ .get,使repsonse具有更大的靈活性 – charlietfl 2012-03-07 06:44:47
我將您的代碼複製/粘貼到我的測試頁,並且效果很好。我沒有全部的CSS細節,顯然是使用jQuery 1.7.1,並且頂部有HTML5 Doctype聲明,並且正在Chrome中進行測試。儘管我可能會嘗試使用'.get()',就像@charlietfl建議的那樣。 – 2012-03-07 08:11:27