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

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

java - SmsManager sending message more than one -