【问题标题】:How to add div content inside a jQuery如何在 jQuery 中添加 div 内容
【发布时间】:2019-12-09 11:10:33
【问题描述】:

我正在尝试将 div 内部的内容添加到 jQuery 函数中。请看下面:

我要添加的内容:

<div id="year">2020</div>

我想将 '#year' div 中的年份 '2020' 添加到函数下方显示 '2019' 的位置:

<div id="getting-started"></div>
$('#getting-started').countdown('2019/12/24', function(event) { // <-- here
    $(this).html(event.strftime('%D %H %M %S'));
});

提前谢谢你:)

【问题讨论】:

  • 试试:- $('#getting-started').countdown($('#year').text() +'/12/24', function(event) { $(this).html(event.strftime('%D %H %M %S')); });
  • Fuzion619 你检查解决方案了吗?

标签: jquery countdown


【解决方案1】:

只需提取#year div 的内容,然后使用该值创建字符串

const year = $('#year').text();
$('#getting-started').countdown(`${year}/12/24`, function(event) {
  $(this).html(event.strftime('%D %H %M %S'));
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多