[SOLVED]jQuery replace.
Posted: Sat Nov 03, 2007 6:59 pm
Hey, I'm trying to take the value of an input element and and place into a h2 element. So I'm using jquery to do this.
But here's the problem. If I have two spaces in the input element the h2 element would only have one. So I figured:
would suffice. But results are not as expected:
"This and That" becomes "This and That"
This is clearly not what I intended. Why isn't the [ ]s working?
I appreciate someone making sense out of this.
Thanks for reading.
Code: Select all
$("#theh2").text($("#theinput").val());
Code: Select all
$("#theh2").text($("#theinput").val().replace(" ", " ");
"This and That" becomes "This and That"
This is clearly not what I intended. Why isn't the [ ]s working?
I appreciate someone making sense out of this.
Thanks for reading.