首页 > Web开发 > 详细

js&jquery避免报错的方法

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

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避免报错的方法

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!