-
切换tab,并且动态添加标签
<script type="text/javascript">
/*处理ie7、ie8不兼容getElementsByClassName*/
if(!document.getElementsByClassName) {
document.getElementsByClassName = function(className, element) {
var children = (element || document).getElementsByTagName('*');
var elements = new Array();
for (var i=0;i<children.length;i++) {
var child = children[i];
var classNames = child.className.split(' ');
for (var j=0;j<classNames.length;j++) {
if (classNames[j] == className) {
elements.push(child);
break;
}
}
}
return elements;
};
}
var newNode = document.createElement("i");
var _titles = document.getElementsByClassName('title');
var _items = document.getElementsByClassName('_items');
var _as = document.getElementsByClassName('title_a');
_items[0].style.display = 'block';
_titles[0].insertBefore(newNode, _as[0]);
for(var i = 0; i <_titles.length; i++){
_titles[i].index = i;
_titles[i].onclick = function (){
for(var j = 0;j< _items.length;j++){
_items[j].style.display = 'none';
}
_items[this.index].style.display = 'block';
_titles[this.index].insertBefore(newNode, _as[this.index]);
}
}
</script>
-
相关阅读:
Struts2知多少(1) Struts2 MVC架构
MyBatis知多少(26)MyBatis和Hibernate区别
MyBatis知多少(26)调试
MyBatis知多少(25)动态SQL
MyBatis知多少(24)存储过程
MyBatis知多少(23)MyBatis结果映射
MyBatis知多少(22)MyBatis删除操作
MyBatis知多少(21)更新操作
MyBatis知多少(20)MyBatis读取操作
MyBatis知多少(19)MyBatis操作
-
原文地址:https://www.cnblogs.com/goweb/p/5756444.html
Copyright © 2020-2023
润新知