jQuery childrenallows you to filter by selector, which is not available in the DOM API (you can find all descendants matching the given CSS selector, but you cannot [at the moment] limit it only to children).
If it does not matter whether it is a child or just a descendant, then:
var icon = this.querySelector("i");
, i. , . , , :
<div class="myElement">
<span>
<i>You DON'T want this one</i>
</span>
<i>You do want this one</i>
</div>
, , , :
var icon = null;
var n;
for (n = 0; n < !icon && this.children.length; ++n) {
if (this.children[n].tagName.toLowerCase() === "i") {
icon = this.children[n];
}
}
ES2015 + ( ), :
let icon = Array.from(this.children)
.find(child => child.tagName.toLowerCase() === "i");