var element = document.getElementById('menu') if(!element){ alert('0') } else{ alert('1') }
<!DOCTYPE html> <html ng-app> <head> <!-- <script src='http://code.jquery.com/jquery-latest.js'></script> <script src="http://code.angularjs.org/1.1.4/angular.min.js"></script> <link rel='stylesheet type=text/css href=tmp.css' /> --> <style type='text/css'> </style> <script type='text/javascript'> var element = document.getElementById('menu') if(!element){ alert('0') } else{ alert('1') } </script> </head> <body> </body> </html>
var element = $('#menu'); if(!element.length)