Ok, so i assume you want to do this:
(given an image)
HTML:
<img id="img" src="image.png">
now, to get the x and y pos:
javascript:
function getCoordsOfElement(query) {
var el = document.querySelector(query);
var offset = el.getBoundingClientRect();
return {
x: offset.left,
y: offset.top
};
}
// get the x and y offset of the image
var offset = getCoordsOfElement('#img');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.