<meta http-equiv="content-type" content="text/html;charset=utf-8" />
  <meta name="generator" content="" />
  <meta name="author" content="" />
        <meta name="keywords" content="" />
        <meta name="robots" content="index, follow" />
        <meta name="googlebot" content="index, follow" />
  <title>     </title>
  <link rel="stylesheet" type="text/css" href=""  media="all" />
  <script type="text/javascript">
   function exist(id){
    var s=document.getElementById(id);
    if(s){return true}
    else{return false}
   }
   window.onload=function(){
    alert(exist("wrapper"));
    alert(exist("111"))
   }
  </script>
 </head>
 <body>
  <div ></div>
 </body>
</html>

  如果在后台生成控件的话,如果有显示与否的控制的话,会出现找不到对象的异常(脚本错误),需要加判断。

如何用JS判断网页中某个id的网页元素是否存在

相关文章:

  • 2022-02-02
  • 2022-12-23
  • 2021-12-27
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-17
  • 2021-09-02
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案