Last active
February 29, 2020 02:00
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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