HTML inputBox 아래에 div붙이기 천상의날개 2013. 2. 27. 17:17 inputBox 아래에 div붙이기 <html> <head> </head> <script> function test(){ var inputBox = document.getElementById("aa"); var testDiv = document.getElementById("testDiv"); testDiv.style.top=inputBox.offsetTop+inputBox.offsetHeight; testDiv.style.left=inputBox.offsetLeft; } function test1(){ var inputBox = document.getElementById("aa1"); var testDiv = document.getElementById("testDiv"); testDiv.style.top=inputBox.offsetTop+inputBox.offsetHeight; testDiv.style.left=inputBox.offsetLeft; } </script> <body> asdflkjasldf<br> sdfasdfasdf<br> asdasd<br> <input type="text" id="aa" onclick="test()"/> asdasd<br> asdasd<br> <div id="testDiv"style="position:absolute;background-color:red;width:100px;height:100px;z-index:1000;top:0px;left:700px;"></div> <input type="text" id="aa1" onclick="test1()"/> </body> </html>