我使用ajax加載div內的一些內容,並且這包括jQueryVericalTabs插件。然而,這些樣式不起作用,我只能看到未格式化的文本。無法在ajax加載內執行javascript div
使用FF的網頁開發工具,我發現呈現的源文件並沒有鏈接到CSS文件上的樣式,儘管在索引頁上正確調用了。我試圖直接在index.php上編寫CSS,放在內容文件中,把它放在body標籤中,有和沒有javascript(每個插件的演示),還有關於this post的建議,但都沒有工作,不知道還有什麼嘗試。下面是我的頭看起來像:
<link rel="stylesheet" href="css/jquery-jvert-tabs-1.1.4.css" type="text/css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/jquery-jvert-tabs-1.1.4.js"></script>
<script type="text/javascript" src="js/ajax.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(function(){
$("#accordion").accordion({
active: false,
autoHeight: false,
collapsible: true
});
});
$("#vtabs5").jVertTabs({
equalHeights: true
});
// add click events for open tab buttons
$("input[id^=openTab]").each(function(index){
$(this).click(function(){
openTab("#vtabs6",index);
return false;
});
});
function openTab(tabId,index){
$(tabId).jVertTabs('selected',index);
}
});
我嘗試了不同的插件,verticalTabs和製表標題顯示具有正確的格式,但不顯示選項卡的內容。儘管如此,我仍然傾向於使用第一個插件,但HTML更清晰。
我很欣賞任何輸入。
我知道這是一個老問題/答案,但'.live()'在jQuery 1.7上已棄用,大約半年後,它在1.9上完全刪除。改用'.on()'。 – Pere 2014-11-13 15:59:51