I'm using google maps for my website.Below code is working with HTML id element, and I need to use it in class elements.
<script type="text/javascript">
function initialize() {
var coords = document.getElementById('coords').innerHTML.split(",");
var lat = coords[0];
var lng = coords[1];
var myOptions = {
center: new google.maps.LatLng(lat, lng),
zoom: 17,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);
var myMarkerLatlng = new google.maps.LatLng(lat,lng);
var marker = new google.maps.Marker({
position: myMarkerLatlng,
map: map,
title: 'Hello World!'
});
}
</script>
In the above code I'm using the below code line to get element by ID:
var coords = document.getElementById('coords').innerHTML.split(",");
But, I want to use this code to work with class elements.
Any solution would be great.
Thanks in Advanced.