记录:清空方括号功能出现的bug
$(document).on("turbolinks:load", function() {
  $("#clear-white-page-3").click(function(e) {
      e.preventDefault(e);
      $(':contains([)').each(function(e){
          $("div#resume_white_html2").html($("div#resume_white_html2").html().split("[").join(""));
       });
      $(':contains(])').each(function(e){
          $("div#resume_white_html2").html($("div#resume_white_html2").html().split("]").join(""));
       });
  });
});

原先的清楚方括号的功能是这样的,对对象的HTML进行操作,但最近因为新加功能发现这个功能对复制进入文本框的文字不起作用。 需要改变一下功能的作用域$("").val。将HTMl换成val或者是text就可以了


The problem with using $('textarea').text('') , or $('textarea').html('') for that matter is that it will only erase what was in the original DOM sent by the server. If a user clears it and then enters new input, the clear button will no longer work. Using .val('') handles the user input case properly.

1