使用jquery附加Adsence代码

时间:2015-04-28 21:18:27

标签: jquery adsense

我有adsense代码,我想用jquery

将其附加到div
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-XXXX" data-ad-slot="XXXXX" data-ad-format="auto"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});
</script>

但它打破了我的所有剧本, 我这样做:

var script ='<?php echo preg_replace("/[\n\r]/","",html_entity_decode($jobsideads[0]['script'])); ?>';
jQuery(script).appendTo('#tab1');

1 个答案:

答案 0 :(得分:0)

此代码中有错误

var script ='<?php echo preg_replace("/[\n\r]/","",html_entity_decode($jobsideads[0]['script'])); ?>';
jQuery(script).appendTo('#tab1');

将其更改为

var script ='<?php echo preg_replace("/[\n\r]/","",html_entity_decode($jobsideads[0]["script"])); ?>';
jQuery('#tab1').append(script);