1

我想在用户点击时显示 google dfp unitnavbar

$(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吗?如果没有,那么我该如何实施?

4

2 回答 2

1

您需要包含 jQuery,将其添加到您的<head>

<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
于 2017-09-25T08:30:03.940 回答
1

您缺少jQuery库,您需要head section在任何其他库包含之前将其包含到。

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

希望这会帮助你。

于 2017-09-25T08:30:39.053 回答