首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在url的末尾锚定

在url的末尾锚定
EN

Stack Overflow用户
提问于 2017-05-02 14:24:39
回答 1查看 46关注 0票数 0

我必须在下面的js中添加几行。我想要做的是在URL“%cta%%”的末尾添加一个#id。有人能帮我吗?非常感谢!

代码语言:javascript
复制
thisthing.replaceData = function (thisTemplate, htmlList, htmlOverlayer, dataJs, indexLi) {
    //thisTemplate = thisTemplate.replace('%%img%%', '/B2C/ResourcesWebRevise/booking/thisthing/custom/' + dataJs + '.jpg');
    thisTemplate = thisTemplate.replace('%%title%%', thisthingData.title);
    thisTemplate = thisTemplate.replace('%%desc%%', thisthingData.desc);
    thisTemplate = thisTemplate.replace('%%cta%%', thisthingData.cta); // bridge cta
    thisTemplate = thisTemplate.replace('%%list%%', htmlList);
    thisTemplate = thisTemplate.replace('%%overlayer%%', htmlOverlayer);
    thisthing.print(thisTemplate, dataJs, indexLi);
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-05-02 14:26:20

希望这就是你所需要的。只需使用+=添加到字符串的末尾即可。

代码语言:javascript
复制
thisthing.replaceData = function(thisTemplate, htmlList, htmlOverlayer, dataJs, indexLi) {
  //thisTemplate = thisTemplate.replace('%%img%%', '/B2C/ResourcesWebRevise/booking/thisthing/custom/' + dataJs + '.jpg');
  thisTemplate = thisTemplate.replace('%%title%%', thisthingData.title);
  thisTemplate = thisTemplate.replace('%%desc%%', thisthingData.desc);
  thisTemplate = thisTemplate.replace('%%cta%%', thisthingData.cta); // bridge cta
  thisTemplate = thisTemplate.replace('%%list%%', htmlList);
  thisTemplate = thisTemplate.replace('%%overlayer%%', htmlOverlayer);
  thisTemplate += "#id"; // Pretty simple
  thisthing.print(thisTemplate, dataJs, indexLi);
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43740364

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档