[英]Google DFP Ad show for click events
I want to show google dfp unit when user click on navbar
我想在用户点击
navbar
时显示 google dfp 单元
$(document).ready(function () {
var navbar = false;
var navslot = null;
$(document).on('click', '.new_car_nav', function(){
navslot = googletag.defineSlot('/10176910/NavBar', [[250, 250]], 'ad_navbar').addService(googletag.pubads());
googletag.enableServices();
googletag.display('ad_navbar');
});
});
Issue is that it gives an error问题是它给出了错误
Exception in queued GPT command TypeError: $ is not defined
Either we can use jquery in it or not?我们是否可以在其中使用 jquery? If no then how can I implement it?
如果没有,那么我该如何实施呢?
您需要包含 jQuery,将其添加到您的<head>
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
You are missing jQuery
library, you need to include it into the head section
before any other library includes.您缺少
jQuery
库,您需要在包含任何其他库之前将其包含到head section
。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Hope this will help you.希望这会帮助你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.