Reputation: 1406
I have an image map and i want to have the x1,y1,x2,y2 separate in different variables, this is the map:
<area shape="rect"
coords="470,555,863,665"
id="map"
href="#"
this is how to get the coords out of it:
var myVar = (document.getElementById("map").coords);
but the output of this line is "470,555,863,665" is it possible to separate them into different variables?
thanks
Upvotes: 0
Views: 1268
Reputation: 7954
var myVar = (document.getElementById("map").coords).split(',');
//myVar will be an array of all those values
Upvotes: 1
Reputation: 5674
var coords = myVar.split(",");
coords
is now an array of the individual values in the comma separated list. So x1 = coords[0]
, y1 = coords[1]
, etc.
Upvotes: 2