简体   繁体   中英

String Concatenation with JQuery

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

尝试这个:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM