Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: abc.getAttribute is not a function

Tags:

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?

like image 957
Victor Avatar asked Aug 10 '13 15:08

Victor


1 Answers

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);
like image 153
Ivan Chernykh Avatar answered Oct 13 '22 04:10

Ivan Chernykh