日期:2014-05-17 浏览次数:20582 次
<script type="text/javascript">
window.onload = function(){
var _as = document.getElementsByTagName('a');
for(var i = 0 ; i < _as.length ; ++i){
_as[i].length = _as.length;
_as[i].onclick = function(){
for(var j = 0 ; j < this.length ; ++j){
_as[j].className='';
}
this.className = 'selected';
}
}
}
</script>
<style type="text/css">
a{
cursor: pointer;
}
.selected{
color:red;
}
</style>
<a>1</a>
<a>2</a>
<a>3</a>
<a>4</a>