我已經能夠使用Load HTML page dynamically into div with jQuery提供的答案在過去完美加載html到div中,但是,我開始的一個新項目是基於codrops模板(multi-level push menu) ,該網頁不加載到指定。內容格Html沒有動態加載Div Div
的網頁是here。我已經加載了所有正確的jquery庫,並且測試頁面「bio.html」正確地運行。
我第一UL李菜單列表的鏈接「傳」對工作非常具體,只是測試它的功能。
我使用在jquery的代碼是
$(document).ready(function(){
$("#bio").click(function(){
$('.content').load('bio.html');
//alert("Thanks for visiting!");
});
});
選擇器 「#bio」 已index.html中被應用到
<li><a class="icon icon-male" id="bio">Biography</a></li>
。在類=「內容」 div標籤我有它的CSS設置爲
.content {
color: white;
background: rgba(0,0,0,0.9);
background: -moz-linear-gradient(top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.6) 100%);
background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(0,0,0,0.9)), color-stop(100%, rgba(0,0,0,0.6)));
background: -webkit-linear-gradient(top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.6) 100%);
background: -o-linear-gradient(top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.6) 100%);
background: -ms-linear-gradient(top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.6) 100%);
background: linear-gradient(to bottom, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.6) 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#000000', endColorstr='#000000', GradientType=0);
width: 60%;
border-radius: 2px;
padding: 3em 2em;
max-width: 1200px;
max-height: 800px;
margin: 0 auto;
box-shadow: 0 5px 7px -5px rgba(0,0,0,.7);
}
如果有上面的代碼與無論是不允許被點擊處理程序時的頁面動態加載干擾我不知道。我確實改變了class =「content」 from class =「content clearfix」因爲我現在不太在意使用clearfix hack,這是識別原始元素的唯一變化codrops html。
我在我的控制檯中得到'$未定義',任何人都可以得到相同的結果。 –
是的,'js/linking.js'應該包含在jQuery之後。 – Colandus
我想這可能是因爲你有2個不同版本的jQuery(1.4&1.6)的引用。你可以嘗試刪除其中的一個嗎? –