Easily get a single element with jQuery
1 2 $.first = function(a, b) {return $(a, b).get(0)};
DZone Snippets > ciconia > javascript
12729 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Sharon Rosner http://hiperu.blogspot.com
1 2 $.first = function(a, b) {return $(a, b).get(0)};
1 2 function elementAttributesNS(e, ns) { 3 if (!this.__namespaceRegexps) 4 this.__namespaceRegexps = {}; 5 var regexp = this.__namespaceRegexps[ns]; 6 if (!regexp) { 7 this.__namespaceRegexps[ns] = regexp = 8 ns ? eval("/^" + ns + ":(.+)/") : /^([^:]*)$/; 9 } 10 var result = {}; 11 var atts = e.attributes; 12 var l = atts.length; 13 for (var i = 0; i < l; i++) { 14 var m = atts[i].name.match(regexp); 15 if (m) 16 result[m[1]] = atts[i].value; 17 } 18 return result; 19 }