本文實例講述了jQuery使用load()方法載入另外一個網(wǎng)頁文件內(nèi)的指定標(biāo)簽內(nèi)容到div標(biāo)簽的方法。分享給大家供大家參考。具體分析如下:
jQuery通過load()方法載入另外一個網(wǎng)頁文件內(nèi)的指定標(biāo)簽內(nèi)容到div標(biāo)簽,如果我們可以加載網(wǎng)頁b.html中的id為p1的標(biāo)簽內(nèi)容到網(wǎng)頁a.html的div標(biāo)簽內(nèi)
<!DOCTYPE html><html><head><script src="js/jquery.min.js"></script><script>$(document).ready(function(){ $("button").click(function(){ $("#div1").load("demo_test.txt #p1"); });});</script></head><body><div id="div1"><h2>使用jQuery AJAX改變此處內(nèi)容</h2></div><button>改變外部內(nèi)容</button></body></html>希望本文所述對大家的jQuery程序設(shè)計有所幫助。
新聞熱點(diǎn)
疑難解答