码迷,mamicode.com
首页 > Web开发 > 详细

js&jquery避免报错的方法

时间:2017-03-21 10:36:16      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:ftp   round   jquery   ack   amp   auth   cat   cti   class   

CreateTime--2016年12月8日15:28:40
Author:Marydon
js&jquery规避报错信息的两种方式

<script type="text/javascript">
    $(function() {
        /*方法一:捕获异常*/
        try {
            $(div[id=TreeContainer]).each(function(){
                    $(this).width($(#LeftPage).width());
            });
        } catch (e) {}
        /*方法二:加上非空校验*/
        if ($(div[id=TreeContainer])) {
            $(div[id=TreeContainer]).each(function(){
                $(this).width($(#LeftPage).width());
            });
        }
    });
</script>

 

js&jquery避免报错的方法

标签:ftp   round   jquery   ack   amp   auth   cat   cti   class   

原文地址:http://www.cnblogs.com/Marydon20170307/p/6592905.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!