I am trying to use find() function to get all my children element, with each() function I am expecting it return all element, but it only get first element. Is there any misunderstanding with these two functions?
if ($('.test').length > 0) {
var srcset;
$(".test").each(function(index, ele) {
srcset = $(ele).find("source").attr("srcset");
console.log(srcset);
});
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<picture class="test">
<source srcset="###">
<source srcset="###">
<source srcset="###">
<img src="#" alt="">
</picture>