这个教程中的代码 function g(selector){ var method = selector.substr(0,1) == '.'? 'getElementsByClassName' : 'getElementById'; return document[method](selector.substr(1)); } 上面的g()在浏览器中测试没问题,在执行下面的rsort时 function rsort(n){ var photo_center = g('#photo_'+n); photo_center.className += ' photo_center '; } 讲师直接就执行了,我的浏览器却一直提示photo_center为null 请问下这是什么原因? ff43:TypeError: photo_center is null chrome:Uncaught TypeError: Cannot read property 'className' of null
伊望岁月