Skip to content

Instantly share code, notes, and snippets.

@onozaty
Created February 19, 2013 15:18
Show Gist options
  • Save onozaty/4986781 to your computer and use it in GitHub Desktop.
Save onozaty/4986781 to your computer and use it in GitHub Desktop.
function show(target) {
var div = document.createElement('div');
div.appendChild(document.createTextNode('xxxx'));
div.style.border = 'solid 1px black';
div.style.zindex = 100;
// 対象と同じ親に追加
target.parentElement.appendChild(div);
// 親ボックスからの絶対指定
div.style.position = 'absolute';
// 親ボックスからの位置は、対象と同じ位置から、
// 下に向かって対象の高さ分ずらす
div.style.top = (target.offsetTop + target.offsetHeight) + 'px';
div.style.left = target.offsetLeft + 'px';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment