Reputation: 195
I am not able to display text with backslashes in my textbox. \t places a tab(4 spaces) in the text box like
C: able instead of C:\table
<input type="text" id="input" />
<div>
<input style="margin-top: 20px;" type="button" id='btn' value="Set new value" />
</div>
$('#btn').on('click', function () {
var testval = 'C:\table';
$('#input').val(testval);
});
Is there a way to escape this backslah and display the path completely?
Upvotes: 2
Views: 6886
Reputation: 6266
Escape the backslash as : var testval = 'C:\\table';
or try using
var testval = 'C:\table';
JSON.stringify(testval);
Upvotes: 0
Reputation: 140
Put two backslaces: instead of 'C:\table' -> use 'C:\table'
this works for all languages( that's how you escape special characters )
Upvotes: 1
Reputation: 324
You have to escape the back slash, otherwise it's interpreted as an tab:
"C:\\table"
Upvotes: 7