Skip to content

Instantly share code, notes, and snippets.

@ratiw
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ratiw/9f9a1f27d2af166a365a to your computer and use it in GitHub Desktop.
Save ratiw/9f9a1f27d2af166a365a to your computer and use it in GitHub Desktop.
Combine associative array into html attributes or query string
function makeAttributes(arr, connector, separator) {
var out = '';
if (!connector) connector = '=';
if (!separator) separator = ' ';
for (var k in arr) {
out += (out === '') ? '' : separator;
out += k + connector + arr[k];
}
return out;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment