標籤:
<1>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head> <title></title> <script src="http://localhost:41928/Jquery/jquery-1.10.2.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { var link = $("<a href='http://www.baidu.com'>百度</a>"); //建立一個節點 $("div:first").append(link); //將link節點加入到第一個div中 var link = $("<a href='http://www.google.com.hk'>Google</a>"); //又一次建立一個節點 $("div:last").append(link); //將link節點加入到最後一個div中 }) //====================================================================================== //定義一個字典風格的數組 var data = { "百度": "http://www.baidu.com", "新浪": "http://www.sina.com.cn", "搜狐": "http://www.sohu.com" }; $(function () { $.each(data, function (key, value) { //遍曆這個數組,調用匿名函數進行處理 var link = $("<tr><td><a href=" + value + ">" + key + "</a></td></tr>"); //建立一個節點 $("#table1").append(link); //將這個節點加入到table中 }) }) </script></head><body><div></div><div></div><table id="table1"></table></body></html>
著作權聲明:本文博主原創文章。部落格,未經同意不得轉載。
jquery動態串連節點