2013-01-31 09:10 阅读 31


i do have text-box and two check boxes which i am able to clear its values on button click:

$("#cleartext").live('click', function () {
        $(".check").attr("checked", false);

but i do have a textarea in which i am using the html editor but i am not able to clear the value of it so please suggest me on this the view of this elements are as follows:

    <input type="text" id="title" name="title" required title="required" placeholder="title" data-bind="value:title" />
                            <input type="checkbox" id="active" name="active" class="check" data-bind="checked: active=='true'"  />Active
                            <input type="checkbox" id="logon" name="logon" class="check" data-bind="checked: use_logo=='true'"  />Logo
    <textarea id="iiii" name="iiii" class="htmleditor" rows="9" cols="50" style="width: 600px; height: 190px;"></textarea>
<button type="button" class="btn"  id="cleartext">New Contract</button>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

4条回答 默认 最新

  • 已采纳
    dsfs64664 dsfs64664 2013-01-31 09:37

    If I found correct plugin, below should work fine:

    点赞 评论 复制链接分享
  • doujun7161 doujun7161 2013-01-31 09:15

    Suggestion and Correction

    The function $.live() is deprecated. So change the following code:

    $("body").on('click', "#cleartext", function () {
        $(".check").attr("checked", false);

    Now depending on the textarea, say for eg. Redactor, you need to clear this way:

    点赞 评论 复制链接分享
  • douxiaochun4964 douxiaochun4964 2013-01-31 09:19

    Which HTML editor you are using..

    FCK or similar open source editors have respective methods to clear all contents


    <script type="text/javascript"> 
    function resetEditor(id) {

    For wysihtml5 try below

    var rte = $('#description').wysihtml5();
    点赞 评论 复制链接分享
  • dongmei425373 dongmei425373 2013-01-31 09:25

    As said by Praveen Kumar, $.live() is deprecated. The following should work, and clear the textarea:

    $("body").on("click", "#cleartext", function() {
        $(".check").attr("checked", false);

    But if your function is being called frequently, you should bind $.on() on a closer block. You should also avoid $.parents(), because those functions are heavy.

    点赞 评论 复制链接分享