window.onload
=
function
(){
var links = document.getElementById( ' hrefs ' );
var attrs = [];
var as = links.getElementsByTagName( ' a ' );
for ( var i = 0 , len = as.length; i < len; i ++ ) {
as[i].onclick = function (){
var lTitle = this .getAttribute( ' title ' );
var lName = this .getAttribute( ' name ' );
var lDefault = this .getAttribute( ' default ' );
attrs.push(lTitle, lName, lDefault);
ClickEvent(attrs);
// return false;
}
}
}
function ClickEvent(attrs){
lens = attrs.length;
for ( var j = 0 ; j < lens; j ++ ) {
document.getElementById( ' print ' ).innerHTML += attrs[j] + ' <br /> ' ;
}
}
var links = document.getElementById( ' hrefs ' );
var attrs = [];
var as = links.getElementsByTagName( ' a ' );
for ( var i = 0 , len = as.length; i < len; i ++ ) {
as[i].onclick = function (){
var lTitle = this .getAttribute( ' title ' );
var lName = this .getAttribute( ' name ' );
var lDefault = this .getAttribute( ' default ' );
attrs.push(lTitle, lName, lDefault);
ClickEvent(attrs);
// return false;
}
}
}
function ClickEvent(attrs){
lens = attrs.length;
for ( var j = 0 ; j < lens; j ++ ) {
document.getElementById( ' print ' ).innerHTML += attrs[j] + ' <br /> ' ;
}
}
<
div
id
="hrefs"
>
< a href ="javascript:void(0)" title ="I am title1" name ="I am name1" default ="I am default" > sohu </ a >< br >
< a href ="javascript:void(0)" title ="I am title2" default ="I am default" > sohu22 </ a >< br >
< a href ="javascript:void(0)" title ="I am title3" name ="I am name3" > sohu33 </ a >< br >
< a href ="javascript:void(0)" title ="I am title4" name ="I am name4" default ="I am default" > sohu44 </ a >
</ div >
< div id ="print" ></ div >
< a href ="javascript:void(0)" title ="I am title1" name ="I am name1" default ="I am default" > sohu </ a >< br >
< a href ="javascript:void(0)" title ="I am title2" default ="I am default" > sohu22 </ a >< br >
< a href ="javascript:void(0)" title ="I am title3" name ="I am name3" > sohu33 </ a >< br >
< a href ="javascript:void(0)" title ="I am title4" name ="I am name4" default ="I am default" > sohu44 </ a >
</ div >
< div id ="print" ></ div >
本文转自豪情博客园博客,原文链接:http://www.cnblogs.com/jikey/archive/2009/12/07/1618850.html,如需转载请自行联系原作者