Simple sounding one but cant find the solution :
I have a dynamically generated table (ie so I will never know beforehand how many rows, how high they are, etc etc. ). I have one cell with a button image in it. When I click on the image, I want to get the absolute x and y positions of the top and right values for the button i just clicked.
the reason for this is I have another div that i want to reposition to line up with the row that was just clicked on.
I've already tried creating a click handler for the cell and then using .getAttribute("left") in javascript but that comes back as null.
<td id="test1" onclick="multi(this)">
and the following in my js section :
function multi(buttonClicked) {
var posY = buttonClicked.getAttribute("top");
alert(posY);
}
You should be good with:
var posX = buttonClicked.offsetRight;
var posY = buttonClicked.offsetTop;
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.