{"id":1174,"date":"2024-11-10T11:28:57","date_gmt":"2024-11-10T03:28:57","guid":{"rendered":"https:\/\/fwq.ai\/blog\/1174\/"},"modified":"2024-11-10T11:28:57","modified_gmt":"2024-11-10T03:28:57","slug":"on-is-not-a-function%ef%bc%9a%e4%b8%ba%e4%bb%80%e4%b9%88%e6%88%91%e7%9a%84%e4%bb%a3%e7%a0%81%e6%8a%a5%e9%94%99%ef%bc%8c%e8%af%a5%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/1174\/","title":{"rendered":"$(&#8230;).on is not a function\uff1a\u4e3a\u4ec0\u4e48\u6211\u7684\u4ee3\u7801\u62a5\u9519\uff0c\u8be5\u5982\u4f55\u89e3\u51b3\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173028375924787.jpg\" class=\"aligncenter\" title=\"$(&#8230;).on is not a function\uff1a\u4e3a\u4ec0\u4e48\u6211\u7684\u4ee3\u7801\u62a5\u9519\uff0c\u8be5\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" alt=\"$(&#8230;).on is not a function\uff1a\u4e3a\u4ec0\u4e48\u6211\u7684\u4ee3\u7801\u62a5\u9519\uff0c\u8be5\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>$(&#8230;).on is not a function \u9519\u8bef\uff0c\u65b0\u624b\u7591\u60d1<\/strong><\/p>\n<p>\u5728\u524d\u7aef\u5f00\u53d1\u4e2d\uff0c\u5982\u679c\u4f60\u9047\u5230\u7c7b\u4f3c\u201c$(&#8230;).on is not a function\u201d\u8fd9\u6837\u7684\u62a5\u9519\uff0c\u53ef\u80fd\u7684\u539f\u56e0\u662f\uff1a<\/p>\n<p><strong>jQuery \u7248\u672c\u8fc7\u65e7<\/strong><\/p>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u4e2d\u4f7f\u7528\u4e86 jQuery \u7684 on() \u65b9\u6cd5\uff0c\u4f46\u5982\u679c\u4f7f\u7528\u7684 jQuery \u7248\u672c\u592a\u65e7\uff08\u901a\u5e38\u662f\u4f4e\u4e8e 1.7 \u7248\u672c\uff09\uff0cjQuery \u5c1a\u672a\u652f\u6301 on() \u65b9\u6cd5\u3002on() \u65b9\u6cd5\u662f jQuery 1.7 \u4e2d\u65b0\u5f15\u5165\u7684\uff0c\u7528\u4e8e\u7ed1\u5b9a\u4e8b\u4ef6\u5904\u7406\u51fd\u6570\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n<p>\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<ol>\n<li> <strong>\u5347\u7ea7 jQuery \u7248\u672c\uff1a<\/strong>\u4e0b\u8f7d\u5e76\u5f15\u7528\u8f83\u65b0\u7684 jQuery \u7248\u672c\uff0c\u4f8b\u5982\u81f3\u5c11 1.7 \u6216\u66f4\u9ad8\u7248\u672c\u3002<\/li>\n<li> <strong>\u4f7f\u7528 bind() \u6216 live() \u65b9\u6cd5\uff1a<\/strong>bind() \u548c live() \u662f on() \u65b9\u6cd5\u7684\u66ff\u4ee3\u65b9\u6cd5\uff0c\u5728\u8f83\u65e7\u7248\u672c\u7684 jQuery \u4e2d\u53ef\u7528\u3002\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528\uff1a<\/li>\n<\/ol>\n<pre>$('#btn').bind('click', function() {\n    $('#dialog').show();\n});<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6216<\/p>\n<pre>$('#btn').live('click', function() {\n    $('#dialog').show();\n});<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f$(&#8230;).on is not a function\uff1a\u4e3a\u4ec0\u4e48\u6211\u7684\u4ee3\u7801\u62a5\u9519\uff0c\u8be5\u5982\u4f55\u89e3\u51b3\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>$(&#8230;).on is not a function \u9519\u8bef\uff0c\u65b0\u624b\u7591\u60d1 \u5728\u524d\u7aef\u5f00\u53d1\u4e2d\uff0c\u5982\u679c\u4f60\u9047\u5230\u7c7b\u4f3c\u201c$(&#8230;).on is not a function\u201d\u8fd9\u6837\u7684\u62a5\u9519\uff0c\u53ef\u80fd\u7684\u539f\u56e0\u662f\uff1a jQuery \u7248\u672c\u8fc7\u65e7 \u8fd9\u6bb5\u4ee3\u7801\u4e2d\u4f7f\u7528\u4e86 jQuery \u7684 on() \u65b9\u6cd5\uff0c\u4f46\u5982\u679c\u4f7f\u7528\u7684 jQuery \u7248\u672c\u592a\u65e7\uff08\u901a\u5e38\u662f\u4f4e\u4e8e 1.7 \u7248\u672c\uff09\uff0cjQuery \u5c1a\u672a\u652f\u6301 on() \u65b9\u6cd5\u3002on() \u65b9\u6cd5\u662f jQuery 1.7 \u4e2d\u65b0\u5f15\u5165\u7684\uff0c\u7528\u4e8e\u7ed1\u5b9a\u4e8b\u4ef6\u5904\u7406\u51fd\u6570\u3002 \u89e3\u51b3\u65b9\u6848\uff1a \u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u4ee5\u4e0b\u65b9\u6cd5\uff1a \u5347\u7ea7 jQuery \u7248\u672c\uff1a\u4e0b\u8f7d\u5e76\u5f15\u7528\u8f83\u65b0\u7684 jQuery \u7248\u672c\uff0c\u4f8b\u5982\u81f3\u5c11 1.7 \u6216\u66f4\u9ad8\u7248\u672c\u3002 \u4f7f\u7528 bind() \u6216 live() \u65b9\u6cd5\uff1abind() \u548c live() \u662f on() \u65b9\u6cd5\u7684\u66ff\u4ee3\u65b9\u6cd5\uff0c\u5728\u8f83\u65e7\u7248\u672c\u7684 jQuery \u4e2d\u53ef\u7528\u3002\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528\uff1a $(&#8216;#btn&#8217;).bind(&#8216;click&#8217;, function() { $(&#8216;#dialog&#8217;).show(); }); [&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-1174","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1174","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=1174"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1174\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=1174"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=1174"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=1174"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}