首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将js变量传递给html模板。

将js变量传递给html模板。
EN

Stack Overflow用户
提问于 2017-08-22 11:38:17
回答 1查看 241关注 0票数 0

我已经在js文件中获取了drupal值。我想在html模板中传递这个变量。我想将'anniversaryCount‘包含到我捕获的html template.Now中。

Uncaught :无效正则表达式:/(^区)cbox(.|$)/: RegExp.test ()处的堆栈溢出

代码语言:javascript
复制
(function ($) {
  Drupal.behaviors.one_time_popup = {
    attach: function (context, settings) {
      var anniversaryCount = Drupal.settings.one_time_popup.aniv;
      console.log(anniversaryCount); //prints correct value
      cardTemplate = "<div class='cardTemplate'><span class='birthdayImage'></span><p class='wishes'>Happy Work Anniversary <span id='spl_name'></span> !</p><img src='" + Drupal.settings.publicpath + "/Anniversary_Images/" + anniversaryCount + "Anniversary.jpg'></div>";
    }
  };
}(jQuery));
EN

回答 1

Stack Overflow用户

发布于 2017-08-22 11:47:35

使用jquery将html放到页面中。

$("#your_elemen_id_where_to_put_html").html(cardTemplate);

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45816594

复制
相关文章

相似问题

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