JQuery Get Value From Class Attribute Of Multiple Elements In Array Without Loop June 14, 2022 Post a Comment I have multiple Select dropdown elements with a single class .select 1 Solution 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 code var arr = $.map($('.select'), function (el) { return el.value; }); Copy or without jQuery var elems = document.querySelectorAll('.select'), arr = []; for (var i=elems.length; i--;) arr.push(elems[i].value); Copy but 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 array for 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"