You have 3 errors in your script:
$(#number)
missing quotes in #number
$(...)
returns a jQuery OBJECT, so there is no .replace
method, this method belongs to String.prototype
(JavaScript native)
The closing tags are wrong:
<div><span id="number">1195555666<span><div>
Should be:
<div><span id="number">1195555666</span></div>
The correct one should probably be to use text
or html
which are jQuery methods, like this:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><div><spanid="number">1195555666</span></div>
<script>$('#number').text('(11)95555-6666')</script>
If you want to get the value in console.log
do so:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><div><spanid="number">1195555666</span></div>
<script>
var antigo = $('#number').text(); //Pega valor antigo
$('#number').text('(11)95555-6666'); //Seta valor novo
var novo = $('#number').text(); //Pega valor novo
console.log(antigo);
console.log(novo);
</script>