Skip to content

Instantly share code, notes, and snippets.

@GuyPaddock
Last active February 29, 2020 02:00
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 GuyPaddock/93fbe863389a88fc9f2d495446c2598c to your computer and use it in GitHub Desktop.
Save GuyPaddock/93fbe863389a88fc9f2d495446c2598c to your computer and use it in GitHub Desktop.
Converting an Array or jQuery Object to NodeList (from https://stackoverflow.com/a/13363526/4342230)
var tagAttribute = 'data-tag-for-query';
$(elements).each(function() {
$(this).attr(tagAttribute, 'true');
});
var nodes = document.querySelectorAll('[' + tagAttribute + '="true"]');
Array.prototype.forEach.call(nodes, function(node) {
$(node).removeAttr(tagAttribute);
});
return nodes;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment