TypeError: abc.getAttribute is not a function
javascript, jquery
Solution
Try this may be:
var abc = $(".map-marker:first")[0];
var xyz = abc.getAttribute("data-lat");
console.log(xyz);
Or this:
var abc = $(".map-marker:first");
var xyz = abc.data("lat");
console.log(xyz);
Problem
For the following code: ``` <span class="map-marker" data-lng="101.7113506794"></span> <span class="map-marker" data-lng="101.6311097146"></span> var abc = $('.map-marker:first'); var xyz = abc.getAttribute("data-lat"); console.log(xyz); ``` I get the error message: `TypeError: abc.getAttribute is not a function`. What have I done wrong?