{"id":87,"date":"2021-01-18T14:20:44","date_gmt":"2021-01-18T06:20:44","guid":{"rendered":"http:\/\/gjweb.top\/?p=87"},"modified":"2021-01-18T14:20:45","modified_gmt":"2021-01-18T06:20:45","slug":"html-dom-%e5%af%b9%e8%b1%a1","status":"publish","type":"post","link":"https:\/\/gjweb.top\/?p=87","title":{"rendered":"HTML DOM \u5bf9\u8c61"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Image<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>\u200b \u4ee3\u8868\u7f51\u9875\u7684\u4e00\u4e2aimg\u5143\u7d20<\/li><li><code>var img = new Image()<\/code><\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Select\/Opitons<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>\u5c5e\u6027<\/li><li><strong>.options<\/strong> : \u83b7\u53d6select\u4e0b\u6240\u6709\u7684option\u5bf9\u8c61<ul><li><strong>.option.length<\/strong> : \u8868\u793aselect\u4e0boption\u7684\u4e2a\u6570<\/li><\/ul><\/li><li><strong>.length<\/strong> : \u53ef\u4ee5\u76f4\u63a5\u83b7\u53d6option\u7684\u4e2a\u6570<\/li><li><strong>.value<\/strong> :\u6709\u4e24\u79cd\u60c5\u51b5<ul><li>\u5982\u679c\u9009\u4e2d\u7684option\u6ca1\u6709value\u5c5e\u6027,\u5219\u8fd4\u56devalue\u5c5e\u6027<\/li><li>\u5982\u679c\u9009\u4e2d\u7684option\u6ca1\u6709value\u5c5e\u6027,\u5219\u8fd4\u56de\u5185\u5bb9<\/li><\/ul><\/li><li><strong>.selectedIndex(i)<\/strong> : \u8fd4\u56deoption\u7684\u4e0b\u6807<\/li><li>\u65b9\u6cd5<\/li><li><strong>.add<\/strong> : \u5411select\u6dfb\u52a0\u4e00\u4e2aoption<ul><li>\u95ee\u9898: add \u4e0d\u652f\u6301\u6587\u6863\u7247\u6bb5<\/li><li>\u89e3\u51b3<\/li><li>appendChild()<\/li><\/ul><\/li><li><strong>.remove(i)<\/strong> : \u5220\u9664select\u4e0bi\u4f4d\u7f6e\u7684option<\/li><li>Option\u5bf9\u8c61<\/li><li>\u521b\u5efa<ul><li><code>var opt = new Option(text,value)<\/code><\/li><\/ul><\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">teble<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>\u521b\u5efa\u884c\u5206\u7ec4, \u5220\u9664\u822a\u5206\u7ec4, \u83b7\u5f97\u884c\u5206\u7ec4<\/li><li><code>createXXX();deleteXXX();tab.xxx()<\/code><\/li><li>\u4f8b\u5b50<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/\u521b\u5efa\u4e00\u4e2a\u884c\u5206\u7ec4,\u540c\u65f6\u6dfb\u52a0\u5e26table\u4e2d\r\nvar table = table.deleteThead()\r\n\/\/ \u5220\u9664\u884c\u5206\u7ec4\r\ntable.deleteTHead()\r\n\/\/ \u83b7\u53d6\u884c\u5206\u7ec4\r\ntab.THead<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>\u521b\u5efa\u884c\u5206\u7ec4: \u521b\u5efa , \u5220\u9664, \u83b7\u53d6\u884c<\/li><li><code>.inserRow(i) ; .deleteRow(i) ; .rows<\/code><\/li><li>\u7b80\u5199:<ul><li>inserRow \u8868\u793a\u672b\u884c\u8ffd\u52a0<\/li><\/ul><\/li><li>\u793a\u4f8b<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u6dfb\u52a0\r\n\/*\r\n\t\u8fd4\u56detr\u7684\u76ee\u7684\u662f,\u53ef\u4ee5\u7ee7\u7eed\u60f3tr\u4e2d\u6dfb\u52a0\u4ed6td\r\n*\/\r\nvar tr = thead.inserRow()\r\n\r\n\/\/ \u5220\u9664\r\nthead.deleteRow(i)\r\n\/\/ \u83b7\u53d6\r\nvar trs = thead.rows<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>\u6dfb\u52a0td \u5220\u9664 \u83b7\u53d6<\/li><li><code>.insertCell(i); deleteCell(i); cells<\/code><\/li><li><strong>\u5f3a\u8c03<\/strong><ul><li><strong>insertCell<\/strong>\u53ea\u80fd\u7528\u6765\u6dfb\u52a0td<\/li><\/ul><\/li><li>\u793a\u4f8b<\/li><li><code>var td = tr.insertCell()<\/code><\/li><li>\u5220\u9664\u884c<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ i : tr \u5728\u884c\u5206\u7ec4\u5185\u7684\u4e0b\u6807\r\ntbody.deleteRow(i)\r\n\r\n\/\/ i : \u5728\u6574\u4e2a\u8868\u4e2d\u7684\u4e0b\u6807\r\ntable.deleteRow(i) \r\n\/*\r\n\t\u56e0\u4e3a\u6bcf\u4e2atr\u90fd\u6709tr.rowindex\u8bb0\u5f55\u4e86tr\u5728\u6574\u4e2a\u8868\u4e2d\u7684\u4e0b\u6807\r\n\t\u901a\u5e38\u4f7f\u7528: \"table.deleteRow(tr.rowIndex)\"\r\n*\/<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Form\/Element<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>from<\/strong> \u5bf9\u8c61\u4ee3\u8868\u7f51\u9875\u7684\u4e00\u4e2aform\u5143\u7d20<\/li><li>\u83b7\u53d6<\/li><li><code>var form = document.forms[i\/id\/name]<\/code><\/li><li>\u5c5e\u6027<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>\/*\r\n\t.element  \u83b7\u5f97form\u4e2d\u6240\u6709\u8868\u5355\u5143\u7d20\u7684\u96c6\u5408\r\n\t\t\u83b7\u5f97\u8868\u5355\u5143\u7d20 : form.elements&#91;i\/id\/name]\r\n\t\t\t\u7b80\u5199: \u5982\u679c\u8868\u5355\u5143\u7d20\u6709name\u5c5e\u6027\r\n\t\t\t\t\u53ef\u76f4\u63a5: var elem = form.name\r\n\t\u8868\u5355\u5143\u7d20: \u65b9\u6cd5\r\n\t\t\t\telem.focus() \/\/ \u8ba9elem\u83b7\u53d6\u7126\u70b9\r\n\t\t\t\telem.blur() \/\/ \u8ba9elem\u5931\u53bb\u7126\u70b9\r\n\t.length == element.length \/\/ \u83b7\u53d6form\u8868\u5355\u5143\u7d20\u7684\u4e2a\u6570\r\n*\/<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>\u65b9\u6cd5<\/li><li><code>.submit() \/\/ \u624b\u52a8\u63d0\u4ea4<\/code><\/li><li>\u4e8b\u4ef6<\/li><li><code>onsubmit()<\/code><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Image \u200b \u4ee3\u8868\u7f51\u9875\u7684\u4e00\u4e2aimg\u5143\u7d20 var img = new Image() Select\/Opito [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-87","post","type-post","status-publish","format-standard","hentry","category-dom"],"_links":{"self":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/87","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=87"}],"version-history":[{"count":0,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/87\/revisions"}],"wp:attachment":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=87"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=87"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=87"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}