The page code is as follows:
<code><empty name="search_data">
<div class="box">
<!-- html代码 -->
</div>
</empty>
<script>
var top = $('.box').offset().top;
$("html,body").scrollTop(top);
</script></code>
Copy after login
As above, is a thinkphp syntax tag, which means that when "search_data" does not exist, the div element with class box will be output to the page. On the contrary, if the "search_data" data exists, the page will not have the div box. , in this case, how to avoid js error?