JS常⽤⽅法(获取Class、获取元素样式、事件监听、cookie、
ajax等)
var Util = {};
Util.byClass = function (oClass) {//全局获取
var tags = document.all ? document.all : ElementsByTagName('*');
var arr = [];
var reg = new RegExp("\\b" + oClass + "\\b");
for (var i = 0; i < tags.length; i++) {
if (st(tags[i].className)) {
arr.push(tags[i]);
}
}
return arr;
};
Util.byClass2 = function (parentID, oClass) {//局部获取
var parent = ElementById(parentID);
var tags = parent.all ? parent.all : ElementsByTagName('*');
var arr = [];
var reg = new RegExp("\\b" + oClass + "\\b");
for (var i = 0; i < tags.length; i++) {
if (st(tags[i].className)) {
arr.push(tags[i]);
selenium获取cookie
}
}
return arr;
};