2013-01-21 28 views
1

我有一個圖像(id="plantilla1"),這使得一個HTML格式轉換爲div(id="contenidor_plantilla")。所以當我點擊圖片plantilla1.html可能會被加載到與id="contenidor_plantilla" div。加載不載入任何內容HTML文件

有什麼問題?它什麼都不做!

<a href="#" id="plantilla1"><img class="plantilles" src="imatges/plantilles/plantilla1.gif"></a> 

<div id="contenidor_plantilla">hola</div> 

這是jQuery代碼:

/**************************** TEMPLATE MAKER  ****************/ 
$(function() { 
    $("#plantilla1").click(function() { 
     $("#contenidor_plantilla").load('plantilla1.html'); 
     alert(); 
    }); 
}); 
+2

是相同路徑中的文件嗎? JavaScript控制檯說什麼?你有沒有使用調試器來檢查?也許[FireBug](https://getfirebug.com/)?任何錯誤?你有包含jQuery庫嗎? – ManseUK

+0

嗨, yes plantilla.html與scripts.js位於同一個文件夾中。該功能是在scripts.js – Despertaweb

回答

0

看來,你是不是包括你的jQuery在此之前,在該腳本的頂部script.Add一個jQuery插件:

<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js'> 
</script> 

<script> 
    $(function() { 
     $("#plantilla1").click(function() { 
     $("#contenidor_plantilla").load('plantilla1.html'); 
     alert(); 
     }); 
    }); 
</script> 

按此順序使用它。 and debug the path of your file which you are trying to load

+0

是的,我已經擁有它。我該如何調試? – Despertaweb

+0

檢查網絡選項卡中的瀏覽器控制檯。有錯誤嗎? – Jai