Link to home
Start Free TrialLog in
Avatar of Arnold Layne
Arnold LayneFlag for United States of America

asked on

question about how to use .each() the right way

I want to find all divs with a class of 'addressLocation' within a div with an id of orders. I want to get the text inside each of the returned divs, and append it to a "waypoints" variable, and I'm not doing it the right way. I'm a little confused about the array and accessing objects in it. Here's my code. I'm hoping this is really easy, but I don't know how to do it correctly. Thanks a bunch.
var waypoints = "";
var addressArray = $("#orders").find('.directionsAddress');
    $.each(addressArray, function (index, address) {
        waypoints = waypoints + "|" + addressArray[index].text();
    });

Open in new window

SOLUTION
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Arnold Layne

ASKER

Thanks guys.
You are welcome - thanks for the points.