Reputation: 47
This is my function to add markers via google maps i want the title of the pin to be the name prop on the checkboxArray item and I can only seem to get undefined when i try .name i would love some feedback.
function addMarker() {
console.log(checkboxArray[iterator].name)
markers.push(new google.maps.Marker({
position: things[iterator],
map: map,
title: checkboxArray[iterator].name,
draggable: false,
animation: google.maps.Animation.DROP
}));
iterator++;
}
when i console.log(checkboxArray[iterator].name)
i get undefined
when i console.log(checkboxArray[iterator])
i get <option value="40.7002593,-111.7941413" name="French Fry" selected="" class="in">French Fry</option>
any ideas?
Upvotes: 1
Views: 34
Reputation: 281864
Use getAttribute()
checkboxArray[iterator].getAttribute("name");
Upvotes: 1