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>