the close parenthesis is there, why does it say it is missing the parenthesis?Creating multiline strings in JavaScriptHow to remove close button on the jQuery UI dialog?Why aren't my dynamically-added form inputs posting?What does jQuery.fn mean?Append element problemBind a function to Twitter Bootstrap Modal CloseDisallow Twitter Bootstrap modal window from closingjquery - get src of image set by picturefillWhy does jQuery or a DOM method such as getElementById not find the element?Why does my JavaScript code get a “No 'Access-Control-Allow-Origin' header is present on the requested resource” error when Postman does not?Appending to dynamic content
"I you already know": is this proper English?
Spoken encryption
Is it correct to translate English noun adjuncts into adjectives?
How may I concisely assign different values to a variable, depending on another variable?
Which Roman general was killed by his own soldiers for not letting them to loot a newly conquered city?
(1 of 11: Numberlink) What is Pyramid Cult's Favorite Activity?
Why is my read in of data taking so long?
Why can't my huge trees be chopped down?
Commercial jet accompanied by small plane near Seattle
Is it legal to use cash pulled from a credit card to pay the monthly payment on that credit card?
Can the Artificer's infusions stack? Returning weapon + radiant weapon?
Automatic Habit of Meditation
Is there a reason why I should not use the HaveIBeenPwned API to warn users about exposed passwords?
Can two figures have the same area, perimeter, and same number of segments have different shape?
How to copy a file transactionally?
How can I make sure my players' decisions have consequences?
How do I run a game when my PCs have different approaches to combat?
On the strategic interest of giving long lasting stock orders
How acidic does a mixture have to be for milk to curdle?
How to get the two pictures aligned
What are the exact meanings of roll, pitch and yaw?
Why isn't my platform event chain working?
Why was Sauron not trying to find the Ring, and instead of preparing for war?
Invert Some Switches on a Switchboard
the close parenthesis is there, why does it say it is missing the parenthesis?
Creating multiline strings in JavaScriptHow to remove close button on the jQuery UI dialog?Why aren't my dynamically-added form inputs posting?What does jQuery.fn mean?Append element problemBind a function to Twitter Bootstrap Modal CloseDisallow Twitter Bootstrap modal window from closingjquery - get src of image set by picturefillWhy does jQuery or a DOM method such as getElementById not find the element?Why does my JavaScript code get a “No 'Access-Control-Allow-Origin' header is present on the requested resource” error when Postman does not?Appending to dynamic content
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Why wouldn't this work? I'm not sure why it says there's a syntax error, it says missing a parenthesis for .append() when the ending parenthesis is clearly there (line 32).
I was told the backslash is used for line breaks in .append()
for(var i = 0; i < works.length; ++i)
$('#work').append('
<div class='col-sm'>
<img class='img-responsive' src='" + works[i] + "'>
</div>
'); //THIS IS THE END PARENTHESIS FOR .APPEND()
;
I expect the images in an array to be displayed in my webpage. The array is called 'works'.
jquery
add a comment |
Why wouldn't this work? I'm not sure why it says there's a syntax error, it says missing a parenthesis for .append() when the ending parenthesis is clearly there (line 32).
I was told the backslash is used for line breaks in .append()
for(var i = 0; i < works.length; ++i)
$('#work').append('
<div class='col-sm'>
<img class='img-responsive' src='" + works[i] + "'>
</div>
'); //THIS IS THE END PARENTHESIS FOR .APPEND()
;
I expect the images in an array to be displayed in my webpage. The array is called 'works'.
jquery
4
unescaped single quotes in value
– Taplar
Mar 26 at 16:50
3
try using ticks instead of quotes if you want multi line strings - ` (the thing left of the 1), also solves your unescaped quotes problem
– Pete
Mar 26 at 16:50
2
Just put it all on one line. You're not really improving readability all that much with those line continuation characters, and it makes it more difficult to maintain anyway.
– Robert Harvey♦
Mar 26 at 16:50
add a comment |
Why wouldn't this work? I'm not sure why it says there's a syntax error, it says missing a parenthesis for .append() when the ending parenthesis is clearly there (line 32).
I was told the backslash is used for line breaks in .append()
for(var i = 0; i < works.length; ++i)
$('#work').append('
<div class='col-sm'>
<img class='img-responsive' src='" + works[i] + "'>
</div>
'); //THIS IS THE END PARENTHESIS FOR .APPEND()
;
I expect the images in an array to be displayed in my webpage. The array is called 'works'.
jquery
Why wouldn't this work? I'm not sure why it says there's a syntax error, it says missing a parenthesis for .append() when the ending parenthesis is clearly there (line 32).
I was told the backslash is used for line breaks in .append()
for(var i = 0; i < works.length; ++i)
$('#work').append('
<div class='col-sm'>
<img class='img-responsive' src='" + works[i] + "'>
</div>
'); //THIS IS THE END PARENTHESIS FOR .APPEND()
;
I expect the images in an array to be displayed in my webpage. The array is called 'works'.
jquery
jquery
edited Mar 26 at 16:49
Robert Harvey♦
152k37 gold badges290 silver badges426 bronze badges
152k37 gold badges290 silver badges426 bronze badges
asked Mar 26 at 16:45
Winnie CaiWinnie Cai
81 bronze badge
81 bronze badge
4
unescaped single quotes in value
– Taplar
Mar 26 at 16:50
3
try using ticks instead of quotes if you want multi line strings - ` (the thing left of the 1), also solves your unescaped quotes problem
– Pete
Mar 26 at 16:50
2
Just put it all on one line. You're not really improving readability all that much with those line continuation characters, and it makes it more difficult to maintain anyway.
– Robert Harvey♦
Mar 26 at 16:50
add a comment |
4
unescaped single quotes in value
– Taplar
Mar 26 at 16:50
3
try using ticks instead of quotes if you want multi line strings - ` (the thing left of the 1), also solves your unescaped quotes problem
– Pete
Mar 26 at 16:50
2
Just put it all on one line. You're not really improving readability all that much with those line continuation characters, and it makes it more difficult to maintain anyway.
– Robert Harvey♦
Mar 26 at 16:50
4
4
unescaped single quotes in value
– Taplar
Mar 26 at 16:50
unescaped single quotes in value
– Taplar
Mar 26 at 16:50
3
3
try using ticks instead of quotes if you want multi line strings - ` (the thing left of the 1), also solves your unescaped quotes problem
– Pete
Mar 26 at 16:50
try using ticks instead of quotes if you want multi line strings - ` (the thing left of the 1), also solves your unescaped quotes problem
– Pete
Mar 26 at 16:50
2
2
Just put it all on one line. You're not really improving readability all that much with those line continuation characters, and it makes it more difficult to maintain anyway.
– Robert Harvey♦
Mar 26 at 16:50
Just put it all on one line. You're not really improving readability all that much with those line continuation characters, and it makes it more difficult to maintain anyway.
– Robert Harvey♦
Mar 26 at 16:50
add a comment |
3 Answers
3
active
oldest
votes
If you are using single quotes to enclose your appended string, you should use double quotes inside of those or you need to escape the other single quotes contained in the opening and closing single quotes, I would go with the latter way of doing it, and change to this:
$('#work').append('<div class="col-sm"><img class="img-responsive" src="' + works[i] + '"></div>'); //THIS IS THE END PARENTHESIS FOR .APPEND()
1
Not the down vote, but the use of `` is for escaping the new line, which can be a valid approach.
– Taplar
Mar 26 at 16:52
@Taplar Yeah, I realized that after I read a comment above and updated my answer, thanks for the information, I've never used that before, typically if I append to a string on multiple lines I just use the + sign at the end of a line
– Ryan Wilson
Mar 26 at 16:54
stackoverflow.com/questions/805107/…
– j08691
Mar 26 at 16:56
@Pete thanks, I missed that last one when editing.
– Ryan Wilson
Mar 26 at 16:57
add a comment |
If you are in a position to use ES6, the template literal is here to remove the complexity/annoyance of multi-line string escaping.
const works = ['http://placekitten.com/150/150', 'http://placekitten.com/200/200']
for (let i = 0; i < works.length; ++i)
$('#work').append(`
<div class='col - sm '>
<img class='img - responsive' src='$works[i]' alt=''>
</div>
`);
;
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="work"></div>
add a comment |
Take a look at the syntax highlight, you're closing the quotes and the interpreter is reading variables next to your string literals therefore throwing syntax errors, I'd encourage you to use ES6 Template literals or pay close attention to how you are using single and double quotes
Try this
for(var i = 0; i < works.length; ++i)
$('#work').append(`
<div class='col-sm'>
<img class='img-responsive' src='$works[i]>
</div>
`); //THIS IS THE END PARENTHESIS FOR .APPEND()
;
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55362288%2fthe-close-parenthesis-is-there-why-does-it-say-it-is-missing-the-parenthesis%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you are using single quotes to enclose your appended string, you should use double quotes inside of those or you need to escape the other single quotes contained in the opening and closing single quotes, I would go with the latter way of doing it, and change to this:
$('#work').append('<div class="col-sm"><img class="img-responsive" src="' + works[i] + '"></div>'); //THIS IS THE END PARENTHESIS FOR .APPEND()
1
Not the down vote, but the use of `` is for escaping the new line, which can be a valid approach.
– Taplar
Mar 26 at 16:52
@Taplar Yeah, I realized that after I read a comment above and updated my answer, thanks for the information, I've never used that before, typically if I append to a string on multiple lines I just use the + sign at the end of a line
– Ryan Wilson
Mar 26 at 16:54
stackoverflow.com/questions/805107/…
– j08691
Mar 26 at 16:56
@Pete thanks, I missed that last one when editing.
– Ryan Wilson
Mar 26 at 16:57
add a comment |
If you are using single quotes to enclose your appended string, you should use double quotes inside of those or you need to escape the other single quotes contained in the opening and closing single quotes, I would go with the latter way of doing it, and change to this:
$('#work').append('<div class="col-sm"><img class="img-responsive" src="' + works[i] + '"></div>'); //THIS IS THE END PARENTHESIS FOR .APPEND()
1
Not the down vote, but the use of `` is for escaping the new line, which can be a valid approach.
– Taplar
Mar 26 at 16:52
@Taplar Yeah, I realized that after I read a comment above and updated my answer, thanks for the information, I've never used that before, typically if I append to a string on multiple lines I just use the + sign at the end of a line
– Ryan Wilson
Mar 26 at 16:54
stackoverflow.com/questions/805107/…
– j08691
Mar 26 at 16:56
@Pete thanks, I missed that last one when editing.
– Ryan Wilson
Mar 26 at 16:57
add a comment |
If you are using single quotes to enclose your appended string, you should use double quotes inside of those or you need to escape the other single quotes contained in the opening and closing single quotes, I would go with the latter way of doing it, and change to this:
$('#work').append('<div class="col-sm"><img class="img-responsive" src="' + works[i] + '"></div>'); //THIS IS THE END PARENTHESIS FOR .APPEND()
If you are using single quotes to enclose your appended string, you should use double quotes inside of those or you need to escape the other single quotes contained in the opening and closing single quotes, I would go with the latter way of doing it, and change to this:
$('#work').append('<div class="col-sm"><img class="img-responsive" src="' + works[i] + '"></div>'); //THIS IS THE END PARENTHESIS FOR .APPEND()
edited Mar 26 at 16:57
answered Mar 26 at 16:51
Ryan WilsonRyan Wilson
4,5091 gold badge10 silver badges24 bronze badges
4,5091 gold badge10 silver badges24 bronze badges
1
Not the down vote, but the use of `` is for escaping the new line, which can be a valid approach.
– Taplar
Mar 26 at 16:52
@Taplar Yeah, I realized that after I read a comment above and updated my answer, thanks for the information, I've never used that before, typically if I append to a string on multiple lines I just use the + sign at the end of a line
– Ryan Wilson
Mar 26 at 16:54
stackoverflow.com/questions/805107/…
– j08691
Mar 26 at 16:56
@Pete thanks, I missed that last one when editing.
– Ryan Wilson
Mar 26 at 16:57
add a comment |
1
Not the down vote, but the use of `` is for escaping the new line, which can be a valid approach.
– Taplar
Mar 26 at 16:52
@Taplar Yeah, I realized that after I read a comment above and updated my answer, thanks for the information, I've never used that before, typically if I append to a string on multiple lines I just use the + sign at the end of a line
– Ryan Wilson
Mar 26 at 16:54
stackoverflow.com/questions/805107/…
– j08691
Mar 26 at 16:56
@Pete thanks, I missed that last one when editing.
– Ryan Wilson
Mar 26 at 16:57
1
1
Not the down vote, but the use of `` is for escaping the new line, which can be a valid approach.
– Taplar
Mar 26 at 16:52
Not the down vote, but the use of `` is for escaping the new line, which can be a valid approach.
– Taplar
Mar 26 at 16:52
@Taplar Yeah, I realized that after I read a comment above and updated my answer, thanks for the information, I've never used that before, typically if I append to a string on multiple lines I just use the + sign at the end of a line
– Ryan Wilson
Mar 26 at 16:54
@Taplar Yeah, I realized that after I read a comment above and updated my answer, thanks for the information, I've never used that before, typically if I append to a string on multiple lines I just use the + sign at the end of a line
– Ryan Wilson
Mar 26 at 16:54
stackoverflow.com/questions/805107/…
– j08691
Mar 26 at 16:56
stackoverflow.com/questions/805107/…
– j08691
Mar 26 at 16:56
@Pete thanks, I missed that last one when editing.
– Ryan Wilson
Mar 26 at 16:57
@Pete thanks, I missed that last one when editing.
– Ryan Wilson
Mar 26 at 16:57
add a comment |
If you are in a position to use ES6, the template literal is here to remove the complexity/annoyance of multi-line string escaping.
const works = ['http://placekitten.com/150/150', 'http://placekitten.com/200/200']
for (let i = 0; i < works.length; ++i)
$('#work').append(`
<div class='col - sm '>
<img class='img - responsive' src='$works[i]' alt=''>
</div>
`);
;
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="work"></div>
add a comment |
If you are in a position to use ES6, the template literal is here to remove the complexity/annoyance of multi-line string escaping.
const works = ['http://placekitten.com/150/150', 'http://placekitten.com/200/200']
for (let i = 0; i < works.length; ++i)
$('#work').append(`
<div class='col - sm '>
<img class='img - responsive' src='$works[i]' alt=''>
</div>
`);
;
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="work"></div>
add a comment |
If you are in a position to use ES6, the template literal is here to remove the complexity/annoyance of multi-line string escaping.
const works = ['http://placekitten.com/150/150', 'http://placekitten.com/200/200']
for (let i = 0; i < works.length; ++i)
$('#work').append(`
<div class='col - sm '>
<img class='img - responsive' src='$works[i]' alt=''>
</div>
`);
;
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="work"></div>
If you are in a position to use ES6, the template literal is here to remove the complexity/annoyance of multi-line string escaping.
const works = ['http://placekitten.com/150/150', 'http://placekitten.com/200/200']
for (let i = 0; i < works.length; ++i)
$('#work').append(`
<div class='col - sm '>
<img class='img - responsive' src='$works[i]' alt=''>
</div>
`);
;
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="work"></div>
const works = ['http://placekitten.com/150/150', 'http://placekitten.com/200/200']
for (let i = 0; i < works.length; ++i)
$('#work').append(`
<div class='col - sm '>
<img class='img - responsive' src='$works[i]' alt=''>
</div>
`);
;
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="work"></div>
const works = ['http://placekitten.com/150/150', 'http://placekitten.com/200/200']
for (let i = 0; i < works.length; ++i)
$('#work').append(`
<div class='col - sm '>
<img class='img - responsive' src='$works[i]' alt=''>
</div>
`);
;
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="work"></div>
answered Mar 26 at 17:02
Andy HoffmanAndy Hoffman
11.2k3 gold badges20 silver badges41 bronze badges
11.2k3 gold badges20 silver badges41 bronze badges
add a comment |
add a comment |
Take a look at the syntax highlight, you're closing the quotes and the interpreter is reading variables next to your string literals therefore throwing syntax errors, I'd encourage you to use ES6 Template literals or pay close attention to how you are using single and double quotes
Try this
for(var i = 0; i < works.length; ++i)
$('#work').append(`
<div class='col-sm'>
<img class='img-responsive' src='$works[i]>
</div>
`); //THIS IS THE END PARENTHESIS FOR .APPEND()
;
add a comment |
Take a look at the syntax highlight, you're closing the quotes and the interpreter is reading variables next to your string literals therefore throwing syntax errors, I'd encourage you to use ES6 Template literals or pay close attention to how you are using single and double quotes
Try this
for(var i = 0; i < works.length; ++i)
$('#work').append(`
<div class='col-sm'>
<img class='img-responsive' src='$works[i]>
</div>
`); //THIS IS THE END PARENTHESIS FOR .APPEND()
;
add a comment |
Take a look at the syntax highlight, you're closing the quotes and the interpreter is reading variables next to your string literals therefore throwing syntax errors, I'd encourage you to use ES6 Template literals or pay close attention to how you are using single and double quotes
Try this
for(var i = 0; i < works.length; ++i)
$('#work').append(`
<div class='col-sm'>
<img class='img-responsive' src='$works[i]>
</div>
`); //THIS IS THE END PARENTHESIS FOR .APPEND()
;
Take a look at the syntax highlight, you're closing the quotes and the interpreter is reading variables next to your string literals therefore throwing syntax errors, I'd encourage you to use ES6 Template literals or pay close attention to how you are using single and double quotes
Try this
for(var i = 0; i < works.length; ++i)
$('#work').append(`
<div class='col-sm'>
<img class='img-responsive' src='$works[i]>
</div>
`); //THIS IS THE END PARENTHESIS FOR .APPEND()
;
answered Mar 26 at 16:58
Gerardo SabettaGerardo Sabetta
264 bronze badges
264 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55362288%2fthe-close-parenthesis-is-there-why-does-it-say-it-is-missing-the-parenthesis%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
4
unescaped single quotes in value
– Taplar
Mar 26 at 16:50
3
try using ticks instead of quotes if you want multi line strings - ` (the thing left of the 1), also solves your unescaped quotes problem
– Pete
Mar 26 at 16:50
2
Just put it all on one line. You're not really improving readability all that much with those line continuation characters, and it makes it more difficult to maintain anyway.
– Robert Harvey♦
Mar 26 at 16:50