Home >Web Front-end >JS Tutorial >jquery sets the top value of an element relative to another element (example code)_jquery
$("#button").css("{top":$("#input").offset().top-$("#span2").offset().top $("#input ").height,position:"absolute"});
In this way, wherever the opinion input button is located, the button will be below the input. The same can be applied to the calendar widget below the input text box
1. In jquery, offset().top is relative to the body. In addition, when setting the top value, you need to find the element with a relative value that is closest to the elementYou can write it like this in js:
this.panel.style.top = (xy.y dateObj.offsetHeight) "px";
As shown in the picture: