Jquery Get Value From Class Attribute Of Multiple Elements In Array Without Loop December 25, 2023 Post a Comment I have multiple Select dropdown elements with a single class .select 1Solution 1: No, there's no other way to get the value from multiple elements, you have to iterate over the elements to get the value from each of them.There are other ways to write basically the same codevar arr = $.map($('.select'), function (el) { return el.value; }); Copyor without jQueryvar elems = document.querySelectorAll('.select'), arr = []; for (var i=elems.length; i--;) arr.push(elems[i].value); Copybut they all iterate, there's no other way to do that.Solution 2: You can use jquery $.map function of jquery to deal with elements arrayfor example var arr = []; arr = $.map($(".select"),function(select){ return $(select).val(); }); console.log(arr); Copy Share Post a Comment for "Jquery Get Value From Class Attribute Of Multiple Elements In Array Without Loop"
Post a Comment for "Jquery Get Value From Class Attribute Of Multiple Elements In Array Without Loop"