{"id":31529,"date":"2024-11-25T10:11:06","date_gmt":"2024-11-25T02:11:06","guid":{"rendered":"https:\/\/fwq.ai\/blog\/31529\/"},"modified":"2024-11-25T10:11:06","modified_gmt":"2024-11-25T02:11:06","slug":"length%e4%b8%8esize%e4%bd%bf%e7%94%a8%e5%af%b9%e6%af%94","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/31529\/","title":{"rendered":"length\u4e0esize()\u4f7f\u7528\u5bf9\u6bd4"},"content":{"rendered":"<p style=\"text-align: left\">\u8fd9\u6b21\u7ed9\u5927\u5bb6\u5e26\u6765length\u4e0esize()\u4f7f\u7528\u5bf9\u6bd4\uff0clength\u4e0esize()\u4f7f\u7528\u7684\u6709\u54ea\u4e9b\uff0c\u4e0b\u9762\u5c31\u662f\u5b9e\u6218\u6848\u4f8b\uff0c\u4e00\u8d77\u6765\u770b\u4e00\u4e0b\u3002<\/p>\n<p style=\"text-align: left\">jQuery length\u548csize()\u533a\u522b\u603b\u7ed3\u5982\u4e0b\uff1a<\/p>\n<p style=\"text-align: left\">1.length\u662f\uff0csize()\u662f\u65b9\u6cd5\u3002<\/p>\n<p style=\"text-align: left\">2.\u5982\u679c\u4f60\u53ea\u662f\u60f3\u83b7\u53d6\u5143\u7d20\u7684\u4e2a\u6570\uff0c\u4e24\u8005\u6548\u679c\u4e00\u6837\u65e2 (&#8220;img&#8221;).length\u548c(&#8220;img&#8221;).length\u548c(&#8220;img&#8221;).size() \u83b7\u53d6\u7684\u503c\u662f\u4e00\u6837\u7684\u3002<\/p>\n<p style=\"text-align: left\">3.\u5982\u679c\u8ba1\u7b97\u4e00\u4e2a\u7684\u957f\u5ea6\u6216\u8005\u8ba1\u7b97\u4e00\u4e2a\u6570\u7ec4\u5143\u7d20\u7684\u4e2a\u6570\u5c31\u53ea\u5f97\u7528length, \u5982 $(&#8220;#text&#8221;).val().length\u3002<\/p>\n<p style=\"text-align: left\">&nbsp;\u770b\u770b\u4ed6\u4eec\u7684\u6267\u884c\u65f6\u95f4\uff0chttp:\/\/jsperf.com\/size-vs-length\u7528\u8fd9\u4e2a\u68c0\u6d4b\u7684<\/p>\n<p style=\"text-align: left\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/061\/021\/3ae777bbb8b49ed539e482ba49ac6c3a-0.png\" class=\"aligncenter\" title=\"length\u4e0esize()\u4f7f\u7528\u5bf9\u6bd4\u63d2\u56fe\" alt=\"length\u4e0esize()\u4f7f\u7528\u5bf9\u6bd4\u63d2\u56fe\" \/><\/p>\n<p style=\"text-align: left\">\u4ece\u56fe\u4e2d\u53ef\u4ee5\u770b\u5230size()\u65b9\u6cd5\u6bd4length\u616238%\uff0c\u539f\u56e0\u4f55\u5728\uff1f<\/p>\n<p style=\"text-align: left\">\u539f\u56e0\u5728\u6b64\uff1a<\/p>\n<p style=\"text-align: left\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/061\/021\/3ae777bbb8b49ed539e482ba49ac6c3a-1.jpg\" class=\"aligncenter\" title=\"length\u4e0esize()\u4f7f\u7528\u5bf9\u6bd4\u63d2\u56fe1\" alt=\"length\u4e0esize()\u4f7f\u7528\u5bf9\u6bd4\u63d2\u56fe1\" \/><\/p>\n<p style=\"text-align: left\">\u770b\u770b\u5b98\u7f51\u7684\u89e3\u91ca\uff08http:\/\/api.jquery.com\/size\/\uff09\uff1a<\/p>\n<blockquote style=\"text-align: left\">\n<p style=\"text-align: left\">The .size() method is deprecated as of jQuery 1.8. Use the .length property instead.<\/p>\n<p style=\"text-align: left\">The .size() method is functionally equivalent to the .length property; however, the .length property is preferred because it does not have the overhead of a function call.<\/p>\n<\/blockquote>\n<p style=\"text-align: left\">\u4ece\u4e0a\u53ef\u4ee5\u770b\u51fasize()\u662f\u8c03\u7528length\u5c5e\u6027\u5b9e\u73b0\u7684<\/p>\n<p style=\"text-align: left\">\u5728jquery 1.8\u540e length\u53d6\u4ee3\u4e86 size()&nbsp; ,\u56e0\u4e3alength\u4e0d\u9700\u8981\u8fd4\u56de\u4e00\u4e2a\u51fd\u6570\u8c03\u7528\uff0c\u66f4\u4f18\u79c0\u3002<\/p>\n<blockquote style=\"text-align: left\">\n<p style=\"text-align: left\">Learn from yesterday, live for today, hope for tomorrow.<\/p>\n<\/blockquote>\n<p>\u76f8\u4fe1\u770b\u4e86\u672c\u6587\u6848\u4f8b\u4f60\u5df2\u7ecf\u638c\u63e1\u4e86\u65b9\u6cd5\uff0c\u66f4\u591a\u7cbe\u5f69\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n<p>\u63a8\u8350\u9605\u8bfb\uff1a<\/p>\n<p><\/p>\n<p><\/p>\n<p>\u4ee5\u4e0a\u5c31\u662flength\u4e0esize()\u4f7f\u7528\u5bf9\u6bd4\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>\u8fd9\u6b21\u7ed9\u5927\u5bb6\u5e26\u6765length\u4e0esize()\u4f7f\u7528\u5bf9\u6bd4\uff0clength\u4e0esize()\u4f7f\u7528\u7684\u6709\u54ea\u4e9b\uff0c\u4e0b\u9762\u5c31\u662f\u5b9e\u6218\u6848\u4f8b\uff0c\u4e00\u8d77\u6765\u770b\u4e00\u4e0b\u3002 jQuery length\u548csize()\u533a\u522b\u603b\u7ed3\u5982\u4e0b\uff1a 1.length\u662f\uff0csize()\u662f\u65b9\u6cd5\u3002 2.\u5982\u679c\u4f60\u53ea\u662f\u60f3\u83b7\u53d6\u5143\u7d20\u7684\u4e2a\u6570\uff0c\u4e24\u8005\u6548\u679c\u4e00\u6837\u65e2 (&#8220;img&#8221;).length\u548c(&#8220;img&#8221;).length\u548c(&#8220;img&#8221;).size() \u83b7\u53d6\u7684\u503c\u662f\u4e00\u6837\u7684\u3002 3.\u5982\u679c\u8ba1\u7b97\u4e00\u4e2a\u7684\u957f\u5ea6\u6216\u8005\u8ba1\u7b97\u4e00\u4e2a\u6570\u7ec4\u5143\u7d20\u7684\u4e2a\u6570\u5c31\u53ea\u5f97\u7528length, \u5982 $(&#8220;#text&#8221;).val().length\u3002 &nbsp;\u770b\u770b\u4ed6\u4eec\u7684\u6267\u884c\u65f6\u95f4\uff0chttp:\/\/jsperf.com\/size-vs-length\u7528\u8fd9\u4e2a\u68c0\u6d4b\u7684 \u4ece\u56fe\u4e2d\u53ef\u4ee5\u770b\u5230size()\u65b9\u6cd5\u6bd4length\u616238%\uff0c\u539f\u56e0\u4f55\u5728\uff1f \u539f\u56e0\u5728\u6b64\uff1a \u770b\u770b\u5b98\u7f51\u7684\u89e3\u91ca\uff08http:\/\/api.jquery.com\/size\/\uff09\uff1a The .size() method is deprecated as of jQuery 1.8. Use the .length property instead. The .size() method is functionally equivalent to the .length property; however, the .length property is preferred because it does not have the overhead of a function call. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-31529","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/31529","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=31529"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/31529\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=31529"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=31529"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=31529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}