Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
149
rated 0 times [  152] [ 3]  / answers: 1 / hits: 129605  / 11 Years ago, sat, august 10, 2013, 12:00:00

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?


More From » jquery

 Answers
92

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);

[#76414] Friday, August 9, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
frederickmohamedw

Total Points: 21
Total Questions: 123
Total Answers: 105

Location: The Bahamas
Member since Tue, Apr 27, 2021
3 Years ago
frederickmohamedw questions
Wed, Sep 23, 20, 00:00, 4 Years ago
Sat, Jul 18, 20, 00:00, 4 Years ago
Sun, Apr 26, 20, 00:00, 4 Years ago
Sat, Jan 11, 20, 00:00, 4 Years ago
Fri, Dec 27, 19, 00:00, 4 Years ago
;