2017-09-25 74 views
2

我想表明谷歌DFP机时navbar谷歌DFP广告节目click事件

$(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'); 
    }); 
}); 

问题用户点击的是,它提供了一个错误

Exception in queued GPT command TypeError: $ is not defined 

要么我们可以在它使用jquery或不?如果没有,那我该如何执行它?

回答

1

您需要包括jQuery的,它添加到您的<head>

<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script> 
1

你缺少jQuery库,你需要把它列入到head section任何其他库包括之前。

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 

希望这会对你有所帮助。