{"id":2638,"date":"2024-11-10T08:02:15","date_gmt":"2024-11-10T00:02:15","guid":{"rendered":"https:\/\/fwq.ai\/blog\/2638\/"},"modified":"2024-11-10T08:02:15","modified_gmt":"2024-11-10T00:02:15","slug":"%e5%a6%82%e4%bd%95%e9%80%9a%e8%bf%87%e7%82%b9%e5%87%bb%e8%a1%a8%e6%a0%bc%e8%a1%a8%e5%a4%b4%e5%88%a0%e9%99%a4%e6%95%b4%e5%88%97%e6%95%b0%e6%8d%ae%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/2638\/","title":{"rendered":"\u5982\u4f55\u901a\u8fc7\u70b9\u51fb\u8868\u683c\u8868\u5934\u5220\u9664\u6574\u5217\u6570\u636e\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173081872168639.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u901a\u8fc7\u70b9\u51fb\u8868\u683c\u8868\u5934\u5220\u9664\u6574\u5217\u6570\u636e\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u901a\u8fc7\u70b9\u51fb\u8868\u683c\u8868\u5934\u5220\u9664\u6574\u5217\u6570\u636e\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u70b9\u51fb\u8868\u5934\u5220\u9664\u8868\u5934\u6240\u5c5e\u5217<\/strong><\/p>\n<p>\u95ee\u9898\u63cf\u8ff0\uff1a<\/p>\n<p>\u5982\u4f55\u5b9e\u73b0\u70b9\u51fb\u8868\u683c\u8868\u5934\u540e\u5220\u9664\u8868\u5934\u6240\u5c5e\u7684\u90a3\u4e00\u5217\uff1f<\/p>\n<p>\u89e3\u51b3\u65b9\u6848\uff1a<\/p>\n<p><strong>\u65b9\u6cd5\u4e00\uff1a\u4f7f\u7528\u539f\u751f javascript<\/strong><\/p>\n<ol>\n<li>\u4e3a\u6bcf\u4e2a\u8868\u5934\u6dfb\u52a0\u4e00\u4e2a onclick \u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u3002<\/li>\n<li>\u5728\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u4e2d\uff0c\u83b7\u53d6\u88ab\u70b9\u51fb\u8868\u5934\u7684\u5217\u7d22\u5f15\uff08\u4ece 0 \u5f00\u59cb\uff09\u3002<\/li>\n<li>\u4f7f\u7528 deletecolumn() \u65b9\u6cd5\u5220\u9664\u8868\u683c\u4e2d\u5177\u6709\u8be5\u5217\u7d22\u5f15\u7684\u5217\u3002<\/li>\n<\/ol>\n<p><strong>\u793a\u4f8b\u4ee3\u7801\uff1a<\/strong><\/p>\n<pre>&lt;table&gt;\n  &lt;thead&gt;\n    &lt;tr&gt;\n      &lt;th onclick=\"deletecolumn(this)\"&gt;\u5217 1&lt;\/th&gt;\n      &lt;th onclick=\"deletecolumn(this)\"&gt;\u5217 2&lt;\/th&gt;\n      &lt;th onclick=\"deletecolumn(this)\"&gt;\u5217 3&lt;\/th&gt;\n    &lt;\/tr&gt;\n  &lt;\/thead&gt;\n  &lt;tbody&gt;\n    &lt;!-- \u8868\u683c\u6570\u636e --&gt;\n  &lt;\/tbody&gt;\n&lt;\/table&gt;\n\n&lt;script&gt;\nfunction deletecolumn(th) {\n  \/\/ \u83b7\u53d6\u5217\u7d22\u5f15\n  const index = th.cellindex;\n\n  \/\/ \u5220\u9664\u5217\n  th.parentelement.deletecell(index);\n}\n&lt;\/script&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u65b9\u6cd5\u4e8c\uff1a\u4f7f\u7528 jquery<\/strong><\/p>\n<ol>\n<li>\u4e3a\u6bcf\u4e2a\u8868\u5934\u6dfb\u52a0\u4e00\u4e2a click \u4e8b\u4ef6\u76d1\u542c\u5668\u3002<\/li>\n<li>\u5728\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u4e2d\uff0c\u4f7f\u7528 jquery \u7684 index() \u65b9\u6cd5\u83b7\u53d6\u88ab\u70b9\u51fb\u8868\u5934\u7684\u5217\u7d22\u5f15\u3002<\/li>\n<li>\u4f7f\u7528 jquery \u7684 remove() \u65b9\u6cd5\u5220\u9664\u8868\u683c\u4e2d\u5177\u6709\u8be5\u5217\u7d22\u5f15\u7684\u5217\u3002<\/li>\n<\/ol>\n<p><strong>\u793a\u4f8b\u4ee3\u7801\uff1a<\/strong><\/p>\n<pre>&lt;table&gt;\n  &lt;thead&gt;\n    &lt;tr&gt;\n      &lt;th class=\"delete-column\"&gt;\u5217 1&lt;\/th&gt;\n      &lt;th class=\"delete-column\"&gt;\u5217 2&lt;\/th&gt;\n      &lt;th class=\"delete-column\"&gt;\u5217 3&lt;\/th&gt;\n    &lt;\/tr&gt;\n  &lt;\/thead&gt;\n  &lt;tbody&gt;\n    &lt;!-- \u8868\u683c\u6570\u636e --&gt;\n  &lt;\/tbody&gt;\n&lt;\/table&gt;\n\n&lt;script&gt;\n$(function() {\n  $('.delete-column').click(function() {\n    \/\/ \u83b7\u53d6\u5217\u7d22\u5f15\n    const index = $(this).index();\n\n    \/\/ \u5220\u9664\u5217\n    $(this).parent().siblings('td:nth-child(' + (index + 1) + ')').remove();\n    $(this).remove();\n  });\n});\n&lt;\/script&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u901a\u8fc7\u70b9\u51fb\u8868\u683c\u8868\u5934\u5220\u9664\u6574\u5217\u6570\u636e\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u70b9\u51fb\u8868\u5934\u5220\u9664\u8868\u5934\u6240\u5c5e\u5217 \u95ee\u9898\u63cf\u8ff0\uff1a \u5982\u4f55\u5b9e\u73b0\u70b9\u51fb\u8868\u683c\u8868\u5934\u540e\u5220\u9664\u8868\u5934\u6240\u5c5e\u7684\u90a3\u4e00\u5217\uff1f \u89e3\u51b3\u65b9\u6848\uff1a \u65b9\u6cd5\u4e00\uff1a\u4f7f\u7528\u539f\u751f javascript \u4e3a\u6bcf\u4e2a\u8868\u5934\u6dfb\u52a0\u4e00\u4e2a onclick \u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u3002 \u5728\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u4e2d\uff0c\u83b7\u53d6\u88ab\u70b9\u51fb\u8868\u5934\u7684\u5217\u7d22\u5f15\uff08\u4ece 0 \u5f00\u59cb\uff09\u3002 \u4f7f\u7528 deletecolumn() \u65b9\u6cd5\u5220\u9664\u8868\u683c\u4e2d\u5177\u6709\u8be5\u5217\u7d22\u5f15\u7684\u5217\u3002 \u793a\u4f8b\u4ee3\u7801\uff1a &lt;table&gt; &lt;thead&gt; &lt;tr&gt; &lt;th onclick=&#8221;deletecolumn(this)&#8221;&gt;\u5217 1&lt;\/th&gt; &lt;th onclick=&#8221;deletecolumn(this)&#8221;&gt;\u5217 2&lt;\/th&gt; &lt;th onclick=&#8221;deletecolumn(this)&#8221;&gt;\u5217 3&lt;\/th&gt; &lt;\/tr&gt; &lt;\/thead&gt; &lt;tbody&gt; &lt;!&#8211; \u8868\u683c\u6570\u636e &#8211;&gt; &lt;\/tbody&gt; &lt;\/table&gt; &lt;script&gt; function deletecolumn(th) { \/\/ \u83b7\u53d6\u5217\u7d22\u5f15 const index = th.cellindex; \/\/ \u5220\u9664\u5217 th.parentelement.deletecell(index); } &lt;\/script&gt; \u767b\u5f55\u540e\u590d\u5236 \u65b9\u6cd5\u4e8c\uff1a\u4f7f\u7528 jquery \u4e3a\u6bcf\u4e2a\u8868\u5934\u6dfb\u52a0\u4e00\u4e2a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-2638","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2638","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=2638"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2638\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=2638"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=2638"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=2638"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}