String Concatenation with JQuery Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceIs there an “exists” function for jQuery?Add table row in jQueryHow do I check if an element is hidden in jQuery?Setting “checked” for a checkbox with jQuery?How can I know which radio button is selected via jQuery?How to check whether a checkbox is checked in jQuery?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?jQuery scroll to element“Thinking in AngularJS” if I have a jQuery background?

Passing functions in C++

When is phishing education going too far?

How do I automatically answer y in bash script?

If I can make up priors, why can't I make up posteriors?

Can a zero nonce be safely used with AES-GCM if the key is random and never used again?

Problem when applying foreach loop

Why does this iterative way of solving of equation work?

3 doors, three guards, one stone

How is simplicity better than precision and clarity in prose?

What's the difference between (size_t)-1 and ~0?

Unable to start mainnet node docker container

Did the new image of black hole confirm the general theory of relativity?

What are the performance impacts of 'functional' Rust?

If A makes B more likely then B makes A more likely"

Is it possible to ask for a hotel room without minibar/extra services?

How do you clear the ApexPages.getMessages() collection in a test?

The following signatures were invalid: EXPKEYSIG 1397BC53640DB551

Is there a documented rationale why the House Ways and Means chairman can demand tax info?

Classification of bundles, Postnikov towers, obstruction theory, local coefficients

Fishing simulator

Cold is to Refrigerator as warm is to?

Geometric mean and geometric standard deviation

What LEGO pieces have "real-world" functionality?

Do working physicists consider Newtonian mechanics to be "falsified"?



String Concatenation with JQuery



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experienceIs there an “exists” function for jQuery?Add table row in jQueryHow do I check if an element is hidden in jQuery?Setting “checked” for a checkbox with jQuery?How can I know which radio button is selected via jQuery?How to check whether a checkbox is checked in jQuery?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?jQuery scroll to element“Thinking in AngularJS” if I have a jQuery background?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















So far, I've been trying to make a photo album with different tabs as different albums. To make it work, I used href (as suggested) to link the actual tab (button) with the content but it hasn't been working out for me. My album has to be dynamic so the #albumID inside href has to be dynamic as well.



this is the code. I'm positive the error lies within href here.



var newTab = $('<li class="nav-item"><a class="nav-link active" id=newTabID data-toggle="tab" href="'#' + albumName" role="tab" aria-controls=albumName aria-selected="true">Album</a></li>');


it should theoretically link to a div with ID albumName



I know this might sound annoying as it had been asked several times already, but the answers I've found haven't worked for me or is too difficult for me to understand (since question is not exactly alike).










share|improve this question

















  • 1





    Yes, you've gone wrong with your quotes in that string. But it's much better in general, when inserting HTML elements, to work with the elements themselves, using the DOM to access/modify attributes and children, rather than just inserting a long string of raw HTML. One reason is you avoid "quote headaches" like this one.

    – Robin Zigmond
    Mar 8 at 14:59






  • 1





    var newTab = $('<li class="nav-item"><a class="nav-link active" id=newTabID data-toggle="tab" href="#' + albumName + '" role="tab" aria-controls=albumName aria-selected="true">Album</a></li>');

    – Xatenev
    Mar 8 at 14:59











  • Try this var newTab = $('<li class="nav-item"><a class="nav-link active" id=newTabID data-toggle="tab" href="#$albumName" role="tab" aria-controls=albumName aria-selected="true">Album</a></li>');

    – Esdras Xavier
    Mar 8 at 15:00











  • If you're using any sort of IDE and not just a text editor, then it will highlight exactly where your error is, as it does here on SO in your code in the question. Use ' or " to escape quotes where you need them, but that's not the case here.

    – freedomn-m
    Mar 8 at 15:03











  • Thank you! Both of the codes work. I'm only using notepad++ and I'm just so unfamiliar using quotes like these.

    – Hiro'omi
    Mar 8 at 15:05

















0















So far, I've been trying to make a photo album with different tabs as different albums. To make it work, I used href (as suggested) to link the actual tab (button) with the content but it hasn't been working out for me. My album has to be dynamic so the #albumID inside href has to be dynamic as well.



this is the code. I'm positive the error lies within href here.



var newTab = $('<li class="nav-item"><a class="nav-link active" id=newTabID data-toggle="tab" href="'#' + albumName" role="tab" aria-controls=albumName aria-selected="true">Album</a></li>');


it should theoretically link to a div with ID albumName



I know this might sound annoying as it had been asked several times already, but the answers I've found haven't worked for me or is too difficult for me to understand (since question is not exactly alike).










share|improve this question

















  • 1





    Yes, you've gone wrong with your quotes in that string. But it's much better in general, when inserting HTML elements, to work with the elements themselves, using the DOM to access/modify attributes and children, rather than just inserting a long string of raw HTML. One reason is you avoid "quote headaches" like this one.

    – Robin Zigmond
    Mar 8 at 14:59






  • 1





    var newTab = $('<li class="nav-item"><a class="nav-link active" id=newTabID data-toggle="tab" href="#' + albumName + '" role="tab" aria-controls=albumName aria-selected="true">Album</a></li>');

    – Xatenev
    Mar 8 at 14:59











  • Try this var newTab = $('<li class="nav-item"><a class="nav-link active" id=newTabID data-toggle="tab" href="#$albumName" role="tab" aria-controls=albumName aria-selected="true">Album</a></li>');

    – Esdras Xavier
    Mar 8 at 15:00











  • If you're using any sort of IDE and not just a text editor, then it will highlight exactly where your error is, as it does here on SO in your code in the question. Use ' or " to escape quotes where you need them, but that's not the case here.

    – freedomn-m
    Mar 8 at 15:03











  • Thank you! Both of the codes work. I'm only using notepad++ and I'm just so unfamiliar using quotes like these.

    – Hiro'omi
    Mar 8 at 15:05













0












0








0








So far, I've been trying to make a photo album with different tabs as different albums. To make it work, I used href (as suggested) to link the actual tab (button) with the content but it hasn't been working out for me. My album has to be dynamic so the #albumID inside href has to be dynamic as well.



this is the code. I'm positive the error lies within href here.



var newTab = $('<li class="nav-item"><a class="nav-link active" id=newTabID data-toggle="tab" href="'#' + albumName" role="tab" aria-controls=albumName aria-selected="true">Album</a></li>');


it should theoretically link to a div with ID albumName



I know this might sound annoying as it had been asked several times already, but the answers I've found haven't worked for me or is too difficult for me to understand (since question is not exactly alike).










share|improve this question














So far, I've been trying to make a photo album with different tabs as different albums. To make it work, I used href (as suggested) to link the actual tab (button) with the content but it hasn't been working out for me. My album has to be dynamic so the #albumID inside href has to be dynamic as well.



this is the code. I'm positive the error lies within href here.



var newTab = $('<li class="nav-item"><a class="nav-link active" id=newTabID data-toggle="tab" href="'#' + albumName" role="tab" aria-controls=albumName aria-selected="true">Album</a></li>');


it should theoretically link to a div with ID albumName



I know this might sound annoying as it had been asked several times already, but the answers I've found haven't worked for me or is too difficult for me to understand (since question is not exactly alike).







javascript jquery html






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 8 at 14:56









Hiro'omiHiro'omi

114




114







  • 1





    Yes, you've gone wrong with your quotes in that string. But it's much better in general, when inserting HTML elements, to work with the elements themselves, using the DOM to access/modify attributes and children, rather than just inserting a long string of raw HTML. One reason is you avoid "quote headaches" like this one.

    – Robin Zigmond
    Mar 8 at 14:59






  • 1





    var newTab = $('<li class="nav-item"><a class="nav-link active" id=newTabID data-toggle="tab" href="#' + albumName + '" role="tab" aria-controls=albumName aria-selected="true">Album</a></li>');

    – Xatenev
    Mar 8 at 14:59











  • Try this var newTab = $('<li class="nav-item"><a class="nav-link active" id=newTabID data-toggle="tab" href="#$albumName" role="tab" aria-controls=albumName aria-selected="true">Album</a></li>');

    – Esdras Xavier
    Mar 8 at 15:00











  • If you're using any sort of IDE and not just a text editor, then it will highlight exactly where your error is, as it does here on SO in your code in the question. Use ' or " to escape quotes where you need them, but that's not the case here.

    – freedomn-m
    Mar 8 at 15:03











  • Thank you! Both of the codes work. I'm only using notepad++ and I'm just so unfamiliar using quotes like these.

    – Hiro'omi
    Mar 8 at 15:05












  • 1





    Yes, you've gone wrong with your quotes in that string. But it's much better in general, when inserting HTML elements, to work with the elements themselves, using the DOM to access/modify attributes and children, rather than just inserting a long string of raw HTML. One reason is you avoid "quote headaches" like this one.

    – Robin Zigmond
    Mar 8 at 14:59






  • 1





    var newTab = $('<li class="nav-item"><a class="nav-link active" id=newTabID data-toggle="tab" href="#' + albumName + '" role="tab" aria-controls=albumName aria-selected="true">Album</a></li>');

    – Xatenev
    Mar 8 at 14:59











  • Try this var newTab = $('<li class="nav-item"><a class="nav-link active" id=newTabID data-toggle="tab" href="#$albumName" role="tab" aria-controls=albumName aria-selected="true">Album</a></li>');

    – Esdras Xavier
    Mar 8 at 15:00











  • If you're using any sort of IDE and not just a text editor, then it will highlight exactly where your error is, as it does here on SO in your code in the question. Use ' or " to escape quotes where you need them, but that's not the case here.

    – freedomn-m
    Mar 8 at 15:03











  • Thank you! Both of the codes work. I'm only using notepad++ and I'm just so unfamiliar using quotes like these.

    – Hiro'omi
    Mar 8 at 15:05







1




1





Yes, you've gone wrong with your quotes in that string. But it's much better in general, when inserting HTML elements, to work with the elements themselves, using the DOM to access/modify attributes and children, rather than just inserting a long string of raw HTML. One reason is you avoid "quote headaches" like this one.

– Robin Zigmond
Mar 8 at 14:59





Yes, you've gone wrong with your quotes in that string. But it's much better in general, when inserting HTML elements, to work with the elements themselves, using the DOM to access/modify attributes and children, rather than just inserting a long string of raw HTML. One reason is you avoid "quote headaches" like this one.

– Robin Zigmond
Mar 8 at 14:59




1




1





var newTab = $('<li class="nav-item"><a class="nav-link active" id=newTabID data-toggle="tab" href="#' + albumName + '" role="tab" aria-controls=albumName aria-selected="true">Album</a></li>');

– Xatenev
Mar 8 at 14:59





var newTab = $('<li class="nav-item"><a class="nav-link active" id=newTabID data-toggle="tab" href="#' + albumName + '" role="tab" aria-controls=albumName aria-selected="true">Album</a></li>');

– Xatenev
Mar 8 at 14:59













Try this var newTab = $('<li class="nav-item"><a class="nav-link active" id=newTabID data-toggle="tab" href="#$albumName" role="tab" aria-controls=albumName aria-selected="true">Album</a></li>');

– Esdras Xavier
Mar 8 at 15:00





Try this var newTab = $('<li class="nav-item"><a class="nav-link active" id=newTabID data-toggle="tab" href="#$albumName" role="tab" aria-controls=albumName aria-selected="true">Album</a></li>');

– Esdras Xavier
Mar 8 at 15:00













If you're using any sort of IDE and not just a text editor, then it will highlight exactly where your error is, as it does here on SO in your code in the question. Use ' or " to escape quotes where you need them, but that's not the case here.

– freedomn-m
Mar 8 at 15:03





If you're using any sort of IDE and not just a text editor, then it will highlight exactly where your error is, as it does here on SO in your code in the question. Use ' or " to escape quotes where you need them, but that's not the case here.

– freedomn-m
Mar 8 at 15:03













Thank you! Both of the codes work. I'm only using notepad++ and I'm just so unfamiliar using quotes like these.

– Hiro'omi
Mar 8 at 15:05





Thank you! Both of the codes work. I'm only using notepad++ and I'm just so unfamiliar using quotes like these.

– Hiro'omi
Mar 8 at 15:05












1 Answer
1






active

oldest

votes


















0














Try this:



var newTab = $('<li class="nav-item"><a class="nav-link active" id=newTabID data-toggle="tab" href="#' + albumName+ '" role="tab" aria-controls=albumName aria-selected="true">Album</a></li>');





share|improve this answer























    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
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55065769%2fstring-concatenation-with-jquery%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Try this:



    var newTab = $('<li class="nav-item"><a class="nav-link active" id=newTabID data-toggle="tab" href="#' + albumName+ '" role="tab" aria-controls=albumName aria-selected="true">Album</a></li>');





    share|improve this answer



























      0














      Try this:



      var newTab = $('<li class="nav-item"><a class="nav-link active" id=newTabID data-toggle="tab" href="#' + albumName+ '" role="tab" aria-controls=albumName aria-selected="true">Album</a></li>');





      share|improve this answer

























        0












        0








        0







        Try this:



        var newTab = $('<li class="nav-item"><a class="nav-link active" id=newTabID data-toggle="tab" href="#' + albumName+ '" role="tab" aria-controls=albumName aria-selected="true">Album</a></li>');





        share|improve this answer













        Try this:



        var newTab = $('<li class="nav-item"><a class="nav-link active" id=newTabID data-toggle="tab" href="#' + albumName+ '" role="tab" aria-controls=albumName aria-selected="true">Album</a></li>');






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 8 at 15:07









        Juan Daniel OrnellaJuan Daniel Ornella

        7914




        7914





























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55065769%2fstring-concatenation-with-jquery%23new-answer', 'question_page');

            );

            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







            Popular posts from this blog

            1928 у кіно

            Захаров Федір Захарович

            Ель Греко