728x90
SMALL
#Javascript
String
To use a string as the value of a variable, enclose it in single quotes (') or double quotes (").
var jb = 'Lorem ipsum dolor';
var jb = "Lorem ipsum dolor";
If the string has single quotes, enclose it in double quotes, and if there are double quotes, enclose it in single quotes.
var jb = 'Lorem "ipsum" dolor.';
var jb = "Lorem 'ipsum' dolor.";
If you have single and double quotes, use a backslash.
var jb = 'Lorem "ipsum" \'dolor\'.';
If you need to include a backslash in the string, enter the backslash twice.
var jb = 'Lorem \\ipsum\\ dolor.';
example
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JavaScript</title>
<script>
var jb1 = '1. Lorem ipsum dolor';
var jb2 = "2. Lorem ipsum dolor";
var jb3 = '3. Lorem "ipsum" dolor.';
var jb4 = "4. Lorem 'ipsum' dolor.";
var jb5 = '5. Lorem "ipsum" \'dolor\'.';
var jb6 = '6. Lorem \\ipsum\\ dolor.';
</script>
</head>
<body>
<script>
document.write( '<p>' + jb1 + '</p>' );
document.write( '<p>' + jb2 + '</p>' );
document.write( '<p>' + jb3 + '</p>' );
document.write( '<p>' + jb4 + '</p>' );
document.write( '<p>' + jb5 + '</p>' );
document.write( '<p>' + jb6 + '</p>' );
</script>
</body>
</html>
728x90
LIST
'Javascript' 카테고리의 다른 글
[JavaScript] JavaScript/operator/typeof operator (0) | 2022.08.01 |
---|---|
[Javascript] JavaScript / operator / comparison operator (0) | 2022.07.29 |
[Javascript] Add a comment (0) | 2022.07.27 |
[Javascript] How to put the syntax (0) | 2022.07.27 |
[Javascript] How to insert JavaScript into an HTML document (0) | 2022.07.27 |