Linked Questions
243 questions linked to/from How can I assign a multiline string literal to a variable?
41
votes
9
answers
21k
views
What's the cleanest way to write a multiline string in JavaScript? [duplicate]
It doesn't really have to add newlines, just something readable.
Anything better than this?
str = "line 1" +
"line 2" +
"line 3";
18
votes
6
answers
16k
views
JavaScript Multiline String [duplicate]
The question is:
What is the JavaScript method to store a multiline string into a variable like you can in PHP?
11
votes
3
answers
8k
views
What is the best way to have long string literals in Javascript? [duplicate]
Possible Duplicate:
Multiline strings in Javascript
In Ruby you can do something like this:
temp = <<-SQLCODE
select * from users
SQLCODE
This way you have very long string literals in your ...
0
votes
4
answers
18k
views
How to handle multiple line JavaScript string? [duplicate]
I have got a string from an ajax call. That variable directly comes from a text field from the MySQL database. But after getting that value I'm unable to console log it. By Console debug it is saying ...
7
votes
1
answer
11k
views
Triple Quotation Marks in Javascript [duplicate]
In Python, there are these triple quotation marks ('''), for multiple line strings, which is very useful. Is there any way to do this in javascript?
9
votes
7
answers
299
views
Defining a long string with javascript [duplicate]
I have a simple problem that I just can't seem to figure out. In the code below I get an error (test_str is not defined) because the line defining "var str=" is spread across two lines. After the ...
1
vote
4
answers
7k
views
Set a string of HTML equal to a variable in javascript [duplicate]
I declare a string of HTML and set it equal to a variable. I can't think of any reason it would generate an error, yet here it is:
Uncaught SyntaxError: Unexpected identifier on Ln 136.
Ln 136: ...
3
votes
5
answers
9k
views
How to create multiline string in js [duplicate]
I try to send HTML but I get an error when writing the value at the content key as multiline string. What is the valid syntax for this?
var data = {
"subject":"Test",
...
5
votes
2
answers
6k
views
Custom placeholder inside element <td> not showing [duplicate]
I am using JQuery to dynamically add a new row to a table.
I would like to have a placeholder inside the table cells that go away when the user clicks to enter text.
I attempted to make CSS that would ...
2
votes
1
answer
7k
views
Alternative of triple quoted string in Javascript as Python has [duplicate]
Python has triple quoted string which provides free text input. There is no need next line character to define next line. Here is an example;
hello = """
This string is bounded by ...
-2
votes
2
answers
2k
views
What is the best way to handle large blocks of text in NodeJS? [duplicate]
I am currently building a Slack Bot using Node JS to consume my Rails API.
I'd love to give Slack users who use the bot the option to view detailed help when they put in certain keywords.
Currently, ...
0
votes
2
answers
1k
views
js split by new line (\n) got unexpected token? [duplicate]
says I have a long list of item
a
b
c
I want to quickly split them into array, I did
"a
b
c".split('\n')
but I got Uncaught SyntaxError: Invalid or unexpected token
what's the problem?
4
votes
3
answers
384
views
Why can't I store multi line values into a JavaScript literal? [duplicate]
Possible Duplicates:
a more graceful multi-line javascript string method
Multiline strings in Javascript
window.lastSavedContents = "test
tester";
That's my JavaScript Code. I get a firebug ...
0
votes
1
answer
2k
views
Adding line breaks to a jquery string parameter [duplicate]
I am trying to add a line break to a jQuery parameter string. I have tried \n and + \n + and <br />. Any of these break it. Here is a sample of the code.
$(function() {
$('#products').grid({...
0
votes
1
answer
1k
views
copy and paste a string block to JS code [duplicate]
Possible Duplicate:
How to create multiline strings
is it a way to assign following text to a variable more easily:
line 1
line 2
line 3
instead of:
t="line 1\nline 2\nline 3";
I want copy ...