Single Line Code To Get All HTML Attribute's Value By Attribute Name Using Jquery

This code snippet returns all attribute value from the page by attribute name. 
Code
  1. var attr = 'class'; jQuery('['+attr+']').map(function(index,item){return jQuery(item).attr(attr)}).toArray().join()  
Just change attr name to in above code and this will return all the attribute vlue 
 
Example 1: For src atrribute 
  1. var attr = 'src'; jQuery('['+attr+']').map(function(index,item){return jQuery(item).attr(attr)}).toArray().join()    
Eample 2: For id attribute
  1. var attr = 'id'; jQuery('['+attr+']').map(function(index,item){return jQuery(item).attr(attr)}).toArray().join()     
Example 3: For href attribute
  1. var attr = 'href'; jQuery('['+attr+']').map(function(index,item){return jQuery(item).attr(attr)}).toArray().join()