Share functions to completely replace JavaScript strings. js string functions
In the past few days, the function of Completely replacing JavaScript strings has been used. If you do not need to say anything, simply copy the code and you can:
Copy codeThe Code is as follows:
<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "UTF-8"/>
<Title> </title>
<Script type = "application/javascript">
Function testStr (){
Var temp = document. getElementById ("content"). value;
Var newContent = temp. replace (/"/g ,'\'');
Alert (newContent );
}
</Script>
</Head>
<Body>
<Textarea id = "content"> </textarea>
<Input type = "button" value = "work" onclick = "testStr ();"/>
</Body>
</Html>
The above Code provides the function of replacing quotation marks, And/g indicates that all quotation marks are replaced. Other requirements can be changed. I will take a note here, hoping to help you!