I have:
<input type="text" value="Raphaël\nkicks\nbutt!" id="tzbox_txt">
var inputText = $("#tzbox_txt").val();
var stringText = "Raphaël\nkicks\nbutt!"
inputText === stringText - false!
If I use $(input).val() I get "Raphaël\nkicks\nbutt!" where \n is not being interpreted as line breaks.
And if I do var text = "Raphaël\nkicks\nbutt!" it is being escaped and text shows with line breaks.
How do I make input text value to be interpreted with line breaks?
An
input[type=text]element cannot contain line breaks because thetextinput only accepts a single line of text. What you think of as newline escape sequences are being interpreted as plain text.If you wanted to match it, change your matching code to this because this is exactly what is being returned from the
val()function:If you wanted to match it the other way around, and your
inputelements contain the text sequence of'\n'you could do a replace on the text value before testing: