Reputation: 23
How to convert this jquery code
$(element).find('.ui.dropdown')
to pure JS?
I need to convert a simple code in JQUERY to pure JS.
The element
is a variable in my code, it comes from this code:
$.each($("[action]").toArray(), function(key, element)
Upvotes: 0
Views: 291
Reputation: 3888
How about the following?
Array.prototype.slice.call(document.querySelectorAll('[action]')).forEach(function (element, index) {
element.querySelector('.ui.dropdown')
// do something to the element
});
As noted, Array.prototype.slice()
is only needed if the browser you're running doesn't support NodeList.prototype.forEach()
. For modern browsers you can actually do:
document.querySelectorAll('[action]').forEach(function (element, index) {
element.querySelector('.ui.dropdown')
// do something to the element
});
Upvotes: 1