【问题标题】:Set ID with Jquery getScript使用 Jquery getScript 设置 ID
【发布时间】:2022-01-11 09:09:03
【问题描述】:

我需要用Jquery getScript添加这个脚本,如何添加属性ID?

$.getScript('https://cdn.asksuite.com/infochat.js?dataConfig=https://control.asksuite.com/api/companies/hotel-latitud-buzios', function () {
 ID --> How to add this
});

脚本:

<script id="script-infochat" src='https://cdn.asksuite.com/infochat.js?dataConfig=https://control.asksuite.com/api/companies/hotel-latitud-buzios'></script>

【问题讨论】:

  • 你的ID是什么意思?
  • 这个ID:id="script-infochat"

标签: javascript jquery


【解决方案1】:

getScript 没有使这成为可能的功能。

相反,使用传统方式创建script 元素($('&lt;script&gt;&lt;/script&gt;', attributeObject) 并将其附加到您的文档中。

如果您可以控制要导入的脚本,请考虑使用 currentScript 而不是依赖特定的 ID。

【讨论】:

    猜你喜欢
    • 2010-10-21
    • 1970-01-01
    • 1970-01-01
    • 2012-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多