如何清除AJAX中的textarea字段onclick? [英] How to clear textarea field onclick in AJAX?

查看:61
本文介绍了如何清除AJAX中的textarea字段onclick?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在点击时清除textarea字段?问题是我正在使用 AJAX .它不会重新加载页面.谁能帮我解决这个问题.

How to clear textarea field onclick? the problem is I am using AJAX. it won't reload the page. can anyone help me to solve this problem.

<div class="write_comment" style="">
  <textarea type="text" id="form_task_comment" name="form_task_comment" value="" placeholder="Write your comment here..."></textarea>
  <div class="buttons" style="float:right">
        <button id="btn_comment_submit" class="btn btn-default btn hoverable btn-sm btn_comment_submit" style="margin:0rem;" type="submit">Add Comment</button>
  </div>
</div>

推荐答案

尝试一下.点击按钮清除文本区域

Try this. Click on button to clear Textarea

$('.clearText').click(function(){
  $("#form_task_comment").val('');
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button class="clearText">Click Here To Clear Textarea</button>
<br>
<textarea id="form_task_comment">This is textarea</textarea>

这篇关于如何清除AJAX中的textarea字段onclick?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆