<body>
	<script src="js/Cg.js"></script>
    <div class="basic-portfolio-area ptb-10">
      <div class="filter-menu text-center">
<pre><code>  &lt;/div&gt;
  &lt;div class=&quot;call-to-action-area gray-bg ptb-60&quot;&gt;
    &lt;div class=&quot;container&quot;&gt;
		&lt;div class=&quot;form-group&quot;&gt;
            &lt;label&gt;&lt;/label&gt;
            &lt;textarea class=&quot;form-control&quot; id=&quot;chat-gpt-input&quot; placeholder=&quot;输入问题&quot; rows=&quot;3&quot; resize=&quot;none&quot; style=&quot;width: 100%; margin: 0 auto; background-color: #f4f4f4; color: #333; border: 1px solid #ccc; border-radius: 12px;&quot;&gt;&lt;/textarea&gt;
        &lt;/div&gt;
		&lt;div class=&quot;call-to-action&quot;&gt;
            &lt;a onclick=&quot;callCHATGPT()&quot; class=&quot;btn btn-large&quot; href=&quot;#&quot; id=&quot;call-to-action-btn&quot; style=&quot;background-color: #4cae4c; color: #fff; font-weight: bold; border-radius: 5px; padding: 10px 20px; border: none; box-shadow: none; text-decoration:none;&quot; onmousedown=&quot;this.style.backgroundColor='#3c903c'&quot; onmouseup=&quot;this.style.backgroundColor='#4cae4c'&quot;&gt;回答&lt;/a&gt;
            &lt;a onclick=&quot;clearTextArea()&quot; class=&quot;btn btn-large&quot; href=&quot;#&quot; style=&quot;background-color: #d9534f; color: #fff; font-weight: bold; border-radius: 5px; padding: 10px 20px; border: none; box-shadow: none; text-decoration:none; margin-left: 20px;&quot; onmousedown=&quot;this.style.backgroundColor='#c9302c'&quot; onmouseup=&quot;this.style.backgroundColor='#d9534f'&quot;&gt;清空&lt;/a&gt;
		&lt;/div&gt;
		&lt;div class=&quot;form-group&quot;&gt;
              &lt;label&gt;&lt;/label&gt;
              &lt;textarea class=&quot;form-control&quot; id=&quot;chatgpt-response&quot; placeholder=&quot;长途访问,请耐心等待回答 Ai生成它很快,但是由于网络问题我们需要等待,通常内容越长等待越久 如果长时间没反应请刷新页面重试&quot; rows=&quot;26&quot; resize=&quot;none&quot; style=&quot;width: 100%;height: auto; margin: 0 auto; background-color: #f4f4f4; color: #333; border: 1px solid #ccc; border-radius: 10px; overflow: scroll;&quot;&gt;&lt;/textarea&gt;
        &lt;/div&gt;
	&lt;/div&gt;
	&lt;footer&gt;
		&lt;div class=&quot;basic-footer gray-bg text-center ptb-20&quot;&gt;
			&lt;div class=&quot;container&quot;&gt;
				&lt;div class=&quot;footer-menu mt-30&quot;&gt;
					&lt;p&gt;&lt;a href=&quot;untitled.html&quot;&gt;如果不懂怎么发布命令请进入&lt;/a&gt;&lt;/p&gt;
					&lt;nav&gt;
						&lt;ul&gt;
							&lt;li&gt;&lt;a href=&quot;https://wy2023.icu&quot; target=&quot;_blank&quot;&gt;云客商城&lt;/a&gt;&lt;/li&gt;
							&lt;li&gt;&lt;a href=&quot;https://ai.wy2023.icu/ai-1&quot; target=&quot;_blank&quot;&gt;返回AI-1&lt;/a&gt;&lt;/li&gt;
							&lt;li&gt;&lt;a href=&quot;https://ai.wy2023.icu&quot; target=&quot;_blank&quot;&gt;返回首页&lt;/a&gt;&lt;/li&gt;
						&lt;/ul&gt;
					&lt;/nav&gt;
				&lt;/div&gt;
			&lt;/div&gt;
		&lt;/div&gt;
	&lt;/footer&gt;
&lt;script&gt;
function clearTextArea() {
	document.getElementById(&quot;chat-gpt-input&quot;).value = &quot;&quot;;
	document.getElementById(&quot;chatgpt-response&quot;).value = &quot;&quot;;
	document.getElementById(&quot;call-to-action-btn&quot;).disabled = false;  //添加这一行代码使回答按钮重新可用
} 
    // 添加以下代码,为回答按钮添加点击事件,每次点击时判断输入框是否为空,如果为空则禁用回答按钮
    document.getElementById(&quot;call-to-action-btn&quot;).addEventListener(&quot;click&quot;, function() {
        if (document.getElementById(&quot;chat-gpt-input&quot;).value.trim() === &quot;&quot;) {
            document.getElementById(&quot;call-to-action-btn&quot;).disabled = true;
        }
    });
&lt;/script&gt;
</code></pre>
  </body>
</html>
清空按钮后回答按钮失效的解决方法 - JavaScript代码优化

原文地址: https://www.cveoy.top/t/topic/mmW6 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录