Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extract multiple data from DOM in jQuery?

There is a node like this

<img src=​"http:​/​/​x.JPG" data-latitude=​"0" data-longitude=​"0">​

In jQuery, I can extract two data attribute like this:

a=node.data("latitude")
b=node.data("longitude")

I was wondering whether there is a way to extract multiple data attributes in one time, like this:

latLng = node.data([latitude, longitude]) // not working
like image 415
Hanfei Sun Avatar asked Jul 03 '26 03:07

Hanfei Sun


1 Answers

latLng = node.data();

this return object

{
   latitude:0,
   longitude:0
}
like image 137
user3227295 Avatar answered Jul 05 '26 16:07

user3227295



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!