javascript - How to replace particular string from a multiline textarea using jQuery? -
when have string consists of single line, replace works fine.
as type in text text area , press enter new line, replace won't work anymore.
var currentvalue = $('#service-field').val(); $('#service-field').val(currentvalue.replace("particular string",""));
what should do?
try make sure capture occurrences, , not ones on first line:
$('#service-field').val(currentvalue.replace(/particular string/g, ""));
or variable:
var t = "particular string"; $('#service-field').val(currentvalue.replace(eval("/" + t + "/g"), ""));
Comments
Post a Comment