![](/img/trans.png)
[英]JQuery code is not working using PHP Code for Posts and Pages plugin for Wordpress
[英]jquery code is not working in wordpress plugin
該代碼可以正常工作並加載廣告
<script type="text/javascript">google_ad_client = 'ca-pub-1702577941194110';</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
jQuery不起作用,它在wordpress插件代碼下。
jQuery('#addSpace').html("")
.append("<script type='text/javascript'>"+" google_ad_client ='"+this.title+"'"+ " </" + "script>"+"<script type='text/javascript' src='http://pagead2.googlesyndication.com/pagead/show_ads.js'>"+"</" + "script>");
有人可以幫忙嗎?
某些瀏覽器不會以這種方式更新對HTML的更改。 最好使用內置的fns來實現。
嘗試,
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'http://pagead2.googlesyndication.com/pagead/show_ads.js';
$('#addSpace').append( script );
看起來google_ad_client應該在第一個腳本中只是一個變量,因此您應該首先分配此變量
var google_ad_client = $('#addSpace').attr('title');
然后創建第二個腳本以附加到元素
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'http://pagead2.googlesyndication.com/pagead/show_ads.js';
$('#addSpace').html(script);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.