簡體   English   中英

帶有多個href鏈接的jQuery AJAX加載

[英]jQuery AJAX loading with multiple a href links

大家好,我想讓以下人員正常工作...

  • demo_test.txt加載到“ div1”容器中
  • 僅具有href ID“測試”來觸發它

 <!DOCTYPE html> <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <script> $(document).ready(function() { $("test").click(function() { $("#div1").load("demo_test.txt"); }); }); </script> </head> <body> <div id="div1"> <h2>Let jQuery AJAX Change This Text</h2> </div> <a id="test" href="#">Get External Content</a> <br> <a id="google" href="http://www.google.com/">Google</a> </body> </html> 

目前它沒有運行,但是如果我刪除了Google產品線,它就可以工作。 還有其他我想念的東西嗎? 謝謝!

將您的jQuery click處理程序更改為:

$("#test").click(function() {

我在test前添加了# ,以正確選擇您的錨標記。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM