{"id":642,"date":"2017-03-01T17:20:30","date_gmt":"2017-03-01T09:20:30","guid":{"rendered":"http:\/\/www.qdabc.cn\/?p=642"},"modified":"2017-03-01T16:46:41","modified_gmt":"2017-03-01T08:46:41","slug":"jquery%e5%8a%a8%e6%80%81%e5%88%9b%e5%bb%bahtml%e5%85%83%e7%b4%a0%e7%9a%84%e5%b8%b8%e7%94%a8%e6%96%b9%e6%b3%95%e4%bd%bf%e7%94%a8%e5%bf%83%e5%be%97","status":"publish","type":"post","link":"http:\/\/www.qdabc.cn\/?p=642","title":{"rendered":"jQuery\u52a8\u6001\u521b\u5efahtml\u5143\u7d20\u7684\u5e38\u7528\u65b9\u6cd5\u4f7f\u7528\u5fc3\u5f97"},"content":{"rendered":"<p>1\u3001\u4f7f\u7528jQuery\u521b\u5efa\u5143\u7d20\u7684\u8bed\u6cd5<br \/>\n2\u3001\u628a\u52a8\u6001\u5185\u5bb9\u5b58\u653e\u5230\u6570\u7ec4\u4e2d\uff0c\u518d\u904d\u5386\u6570\u7ec4\u52a8\u6001\u521b\u5efahtml\u5143\u7d20<br \/>\n3\u3001\u4f7f\u7528\u6a21\u7248<\/p>\n<p>1.\u4f7f\u7528jQuery\u52a8\u6001\u521b\u5efa\u5143\u7d20\u8ffd\u52a0\u5230jQuery\u5bf9\u8c61\u4e0a\u3002<\/p>\n<pre class=\"brush:js;toolbar:false\">&lt;meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\"\/&gt;\r\n  &lt;title&gt;&lt;\/title&gt;\r\n  &lt;script src=\"Scripts\/jquery-1.10.2.js\"&gt;&lt;\/script&gt;\r\n  &lt;script type=\"text\/javascript\"&gt;\r\n    $(function() {\r\n      $('&lt;input \/&gt;', {\r\n        id: 'cbx',\r\n        name: 'cbx',\r\n        type: 'checkbox',\r\n        checked: 'checked',\r\n        click: function() {\r\n          alert(\"\u70b9\u6211\u4e86~~\");\r\n        }\r\n      }).appendTo($('#wrap'));\r\n    });\r\n  &lt;\/script&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n  &lt;div id=\"wrap\"&gt;&lt;\/div&gt;\r\n&lt;\/body&gt;<\/pre>\n<p>2.\u5148\u628a\u5185\u5bb9\u653e\u5230\u6570\u7ec4\u4e2d\uff0c\u7136\u540e\u904d\u5386\u6570\u7ec4\u62fc\u63a5\u6210html<\/p>\n<pre class=\"brush:js;toolbar:false\">&lt;head&gt;\r\n&lt;meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\"\/&gt;\r\n  &lt;title&gt;&lt;\/title&gt;\r\n  &lt;script src=\"Scripts\/jquery-1.10.2.js\"&gt;&lt;\/script&gt;\r\n  &lt;style type=\"text\/css\"&gt;\r\n    table {\r\n      border: solid 1px red;\r\n      border-collapse: collapse;\r\n    }\r\n\r\n    td {\r\n      border: solid 1px red;\r\n    }\r\n  &lt;\/style&gt;\r\n  &lt;script type=\"text\/javascript\"&gt;\r\n    $(function () {\r\n      var data = [\"a\", \"b\", \"c\", \"d\"];\r\n      var html = '';\r\n      for (var i = 0; i &lt; data.length; i ++) {\r\n        html += \"&lt;td&gt;\" + data[i] + \"&lt;\/td&gt;\";\r\n      }\r\n      $(\"#row\").append(html);\r\n    });\r\n  &lt;\/script&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n  &lt;table&gt;\r\n    &lt;tr id=\"row\"&gt;&lt;\/tr&gt;\r\n  &lt;\/table&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>\u8fd0\u884c\u6548\u679c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<br \/>\n<img decoding=\"async\" title=\"\" src=\"http:\/\/files.jb51.net\/file_images\/article\/201409\/20149595830110.png?20148595911\" alt=\"\u8fd9\u91cc\u5199\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>3.\u4f7f\u7528\u6a21\u7248\u751f\u6210html<\/p>\n<pre class=\"brush:js;toolbar:false\">&lt;meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\"\/&gt;\r\n  &lt;title&gt;&lt;\/title&gt;\r\n  &lt;script src=\"Scripts\/jquery-1.10.2.js\"&gt;&lt;\/script&gt;\r\n  &lt;script type=\"text\/javascript\"&gt;\r\n    $(function () {\r\n      var a = buildHTML(\"a\", \"\u6211\u662f\u7531\u6a21\u7248\u751f\u6210\u7684\", {\r\n        id: \"myLink\",\r\n        href: \"http:\/\/www.baidu.com\"\r\n      });\r\n\r\n      $('#wrap1').append(a);\r\n\r\n      var input = buildHTML(\"input\", {\r\n        id: \"myInput\",\r\n        type: \"text\",\r\n        value: \"\u6211\u4e5f\u662f\u7531\u6a21\u7248\u751f\u6210\u7684~~\"\r\n      });\r\n\r\n      $('#wrap2').append(input);\r\n    });\r\n\r\n    buildHTML = function(tag, html, attrs) {\r\n      \/\/ you can skip html param\r\n      if (typeof (html) != 'string') {\r\n        attrs = html;\r\n        html = null;\r\n      }\r\n      var h = '&lt;' + tag;\r\n      for (attr in attrs) {\r\n        if (attrs[attr] === false) continue;\r\n        h += ' ' + attr + '=\"' + attrs[attr] + '\"';\r\n      }\r\n      return h += html ? \"&gt;\" + html + \"&lt;\/\" + tag + \"&gt;\" : \"\/&gt;\";\r\n    };\r\n  &lt;\/script&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n  &lt;div id=\"wrap1\"&gt;&lt;\/div&gt;\r\n  &lt;div id=\"wrap2\"&gt;&lt;\/div&gt;\r\n&lt;\/body&gt;<\/pre>\n<p>\u8fd0\u884c\u6548\u679c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<br \/>\n<img decoding=\"async\" title=\"\" src=\"http:\/\/files.jb51.net\/file_images\/article\/201409\/20149595841965.png?20148595857\" alt=\"\u8fd9\u91cc\u5199\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p class=\"post-copyright\">\u6b22\u8fce\u5206\u4eab\u672c\u6587\uff0c\u8f6c\u8f7d\u8bf7\u4fdd\u7559\u51fa\u5904\uff1a<a href=\"http:\/\/www.qdabc.cn\">\u524d\u7aefABC<\/a> &raquo; <a href=\"http:\/\/www.qdabc.cn\/?p=642\">jQuery\u52a8\u6001\u521b\u5efahtml\u5143\u7d20\u7684\u5e38\u7528\u65b9\u6cd5\u4f7f\u7528\u5fc3\u5f97<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>1\u3001\u4f7f\u7528jQuery\u521b\u5efa\u5143\u7d20\u7684\u8bed\u6cd5 2\u3001\u628a\u52a8\u6001\u5185\u5bb9\u5b58\u653e\u5230\u6570\u7ec4\u4e2d\uff0c\u518d\u904d\u5386\u6570\u7ec4\u52a8\u6001\u521b\u5efahtml\u5143\u7d20 3\u3001\u4f7f\u7528\u6a21\u7248 1.\u4f7f\u7528jQuery\u52a8\u6001\u521b\u5efa\u5143\u7d20\u8ffd\u52a0\u5230jQuery\u5bf9\u8c61\u4e0a\u3002 &lt;meta http-e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":87,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,3],"tags":[83,17],"_links":{"self":[{"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/posts\/642"}],"collection":[{"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=642"}],"version-history":[{"count":1,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/posts\/642\/revisions"}],"predecessor-version":[{"id":643,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/posts\/642\/revisions\/643"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/media\/87"}],"wp:attachment":[{"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=642"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=642"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=642"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}