gpt4 book ai didi

javascript - 将字符添加到值中

转载 作者:行者123 更新时间:2023-12-02 19:43:35 25 4
gpt4 key购买 nike

我有一个表格、文本区域和按钮,当用户在文本区域中键入“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() + "(*)",

关于javascript - 将字符添加到值中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10107786/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com