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

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -