Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

replace character inside a string in JavaScript

 function strReplace(){
        var myStr = 'quick_brown_fox';
        var newStr = myStr.replace(/_/g, "-");
        
        // Insert modified string in paragraph
        document.getElementById("myText").innerHTML = newStr;
    }
Source by www.tutorialrepublic.com #
 
PREVIOUS NEXT
Tagged: #replace #character #string #JavaScript
ADD COMMENT
Topic
Name
5+6 =