{"id":2732,"date":"2024-11-10T17:21:06","date_gmt":"2024-11-10T09:21:06","guid":{"rendered":"https:\/\/fwq.ai\/blog\/2732\/"},"modified":"2024-11-10T17:21:06","modified_gmt":"2024-11-10T09:21:06","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-javascript-%e8%8e%b7%e5%8f%96%e5%a4%9a%e4%b8%aa%e9%87%8d%e5%a4%8d-div-%e4%b8%ad%e7%9a%84-input-%e5%92%8c-select-%e5%80%bc%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/2732\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 JavaScript \u83b7\u53d6\u591a\u4e2a\u91cd\u590d div \u4e2d\u7684 input \u548c select \u503c\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173086622297958.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528 JavaScript \u83b7\u53d6\u591a\u4e2a\u91cd\u590d div \u4e2d\u7684 input \u548c select \u503c\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528 JavaScript \u83b7\u53d6\u591a\u4e2a\u91cd\u590d div \u4e2d\u7684 input \u548c select \u503c\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u901a\u8fc7 js \u83b7\u53d6\u591a\u6b21\u91cd\u590d div \u4e2d\u7684 input \u548c select \u503c<\/strong><\/p>\n<p>\u7ed9\u5b9a\u5982\u4e0b html \u7ed3\u6784\uff1a<\/p>\n<pre>&lt;div class=\"fl mr20 shezhishebao\" name=\"shezhishebao\"&gt;\n  &lt;input type=\"text\" class=\"text fl fuwufei\" name=\"fuwufei\" placeholder=\"\u8f93\u5165\u670d\u52a1\u8d39\"&gt;\n  &lt;select class=\"select danwei fl remove\" name=\"danwei\"&gt;\n    &lt;option&gt;\u9009\u62e9\u5355\u4f4d&lt;\/option&gt;\n    &lt;option value=\"1\"&gt;\u6bcf\u6708\/\u6bcf\u4eba&lt;\/option&gt;\n    &lt;option value=\"2\"&gt;\u6bcf\u5b63\/\u6bcf\u4eba&lt;\/option&gt;\n    &lt;option value=\"3\"&gt;\u6bcf\u5e74\/\u6bcf\u4eba&lt;\/option&gt;\n  &lt;\/select&gt;\n  &lt;div class=\"fl ml10\" style=\"padding-top:5px;\"&gt;\n    &lt;em class=\"ico_del\" onclick=\"hezuodel(this)\"&gt;&lt;\/em&gt;\n    &lt;em class=\"ico_add ml5\" onclick=\"hezuoadd(this)\"&gt;&lt;\/em&gt;\n  &lt;\/div&gt;\n&lt;\/div&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8be5 html \u4e2d\u7684 div shezhishebao \u53ef\u80fd\u51fa\u73b0\u591a\u6b21\u3002\u9700\u8981\u83b7\u53d6\u6bcf\u4e2a div \u4e2d\u7684 input fuwufei \u7684\u503c\u548c select danwei \u7684\u503c\u3002<\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528 jquery \u7684 each() \u65b9\u6cd5\u6765\u904d\u5386\u6240\u6709 shezhishebao div\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>$.each($(\"[name='shezhishebao']\"), function(i, e) {\n  console.log($(e).find(\"input[name='fuwufei']\").val());<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4e0a\u9762\u4ee3\u7801\u4f7f\u7528 find() \u65b9\u6cd5\u67e5\u627e\u6bcf\u4e2a div \u4e2d\u7684 input \u548c select\uff0c\u5e76\u5206\u522b\u83b7\u53d6\u5176\u503c\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528 JavaScript \u83b7\u53d6\u591a\u4e2a\u91cd\u590d div \u4e2d\u7684 input \u548c select \u503c\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>\u901a\u8fc7 js \u83b7\u53d6\u591a\u6b21\u91cd\u590d div \u4e2d\u7684 input \u548c select \u503c \u7ed9\u5b9a\u5982\u4e0b html \u7ed3\u6784\uff1a &lt;div class=&#8221;fl mr20 shezhishebao&#8221; name=&#8221;shezhishebao&#8221;&gt; &lt;input type=&#8221;text&#8221; class=&#8221;text fl fuwufei&#8221; name=&#8221;fuwufei&#8221; placeholder=&#8221;\u8f93\u5165\u670d\u52a1\u8d39&#8221;&gt; &lt;select class=&#8221;select danwei fl remove&#8221; name=&#8221;danwei&#8221;&gt; &lt;option&gt;\u9009\u62e9\u5355\u4f4d&lt;\/option&gt; &lt;option value=&#8221;1&#8243;&gt;\u6bcf\u6708\/\u6bcf\u4eba&lt;\/option&gt; &lt;option value=&#8221;2&#8243;&gt;\u6bcf\u5b63\/\u6bcf\u4eba&lt;\/option&gt; &lt;option value=&#8221;3&#8243;&gt;\u6bcf\u5e74\/\u6bcf\u4eba&lt;\/option&gt; &lt;\/select&gt; &lt;div class=&#8221;fl ml10&#8243; style=&#8221;padding-top:5px;&#8221;&gt; &lt;em class=&#8221;ico_del&#8221; onclick=&#8221;hezuodel(this)&#8221;&gt;&lt;\/em&gt; &lt;em class=&#8221;ico_add ml5&#8243; onclick=&#8221;hezuoadd(this)&#8221;&gt;&lt;\/em&gt; &lt;\/div&gt; &lt;\/div&gt; \u767b\u5f55\u540e\u590d\u5236 \u8be5 html \u4e2d\u7684 [&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-2732","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2732","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=2732"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2732\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=2732"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=2732"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=2732"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}