我正在嘗試將外部jquery頁面加載到div中。我使用地圖標記,因爲我的標題的圖像充滿了按鈕。 因此,這是相關代碼將外部文件加載到div中
索引文件:
<script type="text/javascript" src="loader.js"></script>
..
<area shape="rect";
id="find us";
coords="190,50,265,70";
href="javascript:clicked_on('rectangle');"
..
<div id="text">
//where I want the page to be loaded
</div>
加載程序文件:
$(document).ready(function(){
$("#find us").click(function(){
// load contact form onclick
$("#text").load("index.html");
});
});
文件載入:index.html的
當我點擊該圖標就什麼也沒做。 但是,如果我在loader.js包括此代碼開頭,它加載與頁面:
$(document).ready(function(){
// load index page when the page loads
$("#text").load("index.html");
所以圖標不工作..
小時後搜索我放棄..希望在這裏找到答案。 謝謝!
不應該 「我們」 有#或。在它前面?或刪除空間...或添加一個下劃線....東西需要在那裏。從您的編輯中刪除ID中的空格。你在那裏有'#找到#我們'在技術上。 – Scott 2012-02-14 00:25:49