动态创建 div table
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script src="jquery.min.js"></script> <script type="text/javascript"> $(function () { //创建表格 var dic = { "百度": "http://www.baidu.com", "搜狐": "http://www.sohu.com", "谷歌": "https://www.goolge.com" }; var objtab = $("<table border='1'></table>").appendTo($("body")); for (var i in dic) { // alert(i); $("<tr> <td>" + i + "</td><td>"+"<a href="+dic[i]+">" + dic[i] + "</td></a></tr>").appendTo(objtab); } $("#btn1").click(function () { //创建DIV //$('<a href="https:www.baidu.com"></a>').text("百度").appendTo($("body")); var div1 = $("<div></div>").css("width", "200px").css("height", "200px").css("backgroundColor", "green").css("position", "absolute").css("right", "0px").css("bottom", "0px").appendTo($("body")); $("<span><span>").text("关闭").css("float", "right").css("cursor", "pointer").click(function () { $(this).parent().hide(); }).appendTo(div1); }) }); </script> </head> <body> <input type="button" value="jQuery" id="btn1" /> </body> </html>