The page code is as follows: {code ...} as shown above, & amp; lt; empty & amp; gt; is the thinkphp syntax tag, indicating that when "search_data" does not exist, the div element whose class is box will be output to the page. otherwise, if the "search_data" data exists, the page will not have the box div. could you tell me this situation... the page code is as follows:
Script var top = $ ('. box'). offset (). top; $ ("html, body"). scrollTop (top); script
As shown above, It is a thinkphp syntax tag, indicating that when "search_data" does not exist, the p element of the class box will be output to the page. Otherwise, if "search_data" data exists, the page will not have the p box. in this case, how can we avoid js errors?
Reply content:
The page code is as follows:
Script var top = $ ('. box'). offset (). top; $ ("html, body"). scrollTop (top); script
As shown above, It is a thinkphp syntax tag, indicating that when "search_data" does not exist, the p element of the class box will be output to the page. Otherwise, if "search_data" data exists, the page will not have the p box. in this case, how can we avoid js errors?
If ($ ('[name = "search_data]"'). size ()> 0) {// when "search_data" data exists} else {// when "search_data" does not exist}