/**
* 通用函数.
* 1、可以通过ID获取元素
* 2、可以通过class获取元素【是个数组】
*/
function g(selector) {
var method = selector.sub(0, 1) == '.' ? 'getElementByClassName' : 'getElementById';
return document[method](sub(1));
}
JS通用DOM操作函数
/**
* 通用函数.
* 1、可以通过ID获取元素
* 2、可以通过class获取元素【是个数组】
*/
function g(selector) {
var method = selector.sub(0, 1) == '.' ? 'getElementByClassName' : 'getElementById';
return document[method](sub(1));
}
261
506

被折叠的 条评论
为什么被折叠?