![](/img/trans.png)
[英]Printing a HTML + JavaScript variable from an external js to an index.html file using fetch + node.js
[英]Add JavaScript to js file from external html page using jquery
$.ajax({
url: "sub_template5_js.php?content_id="+content_id,
dataType: 'html',
success: function(data){
alert(data);
}
});
在上面的代碼中,當我給警報數據時,我會用js腳本獲取html,我需要分離javascript並將其附加到外部.js文件Pl中。 幫我
謝謝
使用腳本作為選擇器應該可以工作。
$('script').text(); // use attribute selector to get a particular one .
注意:如果您有多個腳本標簽,則必須使用loop。
這只是一個入門的例子...
尚未測試您的數據部分,但您可以嘗試..
data.find('script').text();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.