我有一个表,TextArea和Button,当用户在Textarea中键入诸如“ Hello World!”,然后单击按钮时,我希望文本变为“ Hello World!(*)”。

如何使用我正在使用的Jquery代码做到这一点:

$(document).ready(function () {
     $('#Button').click(function () {
         if ($("#MyTextArea").val().indexOf('|') > -1) {
             alert("The box has special characters. \nThese are not allowed.\n");
         } else {
             if ($.trim($("#MyTextArea").val()).length > 0) {
                 $('#MyTable tbody').append(
                 $('<tr/>', {
                     click: function () {
                         $(this).remove()
                     },
                     html: $("<td />", {
                         html: $("#MyTextArea").val(),
                         'data-sharp-id': 8
                     })
                 }));
                 return false;
             }
         }
     });
 });

最佳答案

改变这个

html: $("#MyTextArea").val(),




html: $("#MyTextArea").val() + "(*)",

07-24 17:59