<a id="data" href="##" data="main_data.html">数据管理</a>
a[i].onclick = function(e){
e.preventDefault();
console.log(this.id);//显示data
console.log(this.data);//显示undefined
console.log(this.getAttibute('data')); //显示main_data.html
//refresh(this.getAttribute('data'));
}
可以看出要获取a标签本身的属性是可以直接用this.+要获取的属性名称;
而如果要获取自定义属性的话要用this.getAttibute('要获取的属性名称');