当我调用“postscribe”时,它表明:
Cannot set property 'postscribe' of null.
我的代码是
$(document).on('click', '.btn', function () {
google_ad_client = "pub-9999999999999999";
google_ad_slot = "9999999999";
google_ad_width = 300;
google_ad_height = 250;
postscribe('#adv1', '<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"><\\/script>');
})
任何人都可以帮忙吗?
最佳答案
此错误意味着您提供给 postscribe 的元素 ( #adv1
) 在您的脚本运行时不存在于 DOM 中。
在运行脚本之前,首先添加 #adv1
到 DOM。你可以这样做:
$("body").append("<div id='adv1'>")
postscribe('#adv1', '<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"><\\/script>');
关于jquery - 无法将属性 'postscribe' 设置为 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41245716/