This code snippet returns all attribute value from the page by attribute name.
Code
- 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
- var attr = 'src'; jQuery('['+attr+']').map(function(index,item){return jQuery(item).attr(attr)}).toArray().join()
Eample 2: For id attribute
- var attr = 'id'; jQuery('['+attr+']').map(function(index,item){return jQuery(item).attr(attr)}).toArray().join()
Example 3: For href attribute
- var attr = 'href'; jQuery('['+attr+']').map(function(index,item){return jQuery(item).attr(attr)}).toArray().join()