[點(diǎn)晴永久免費(fèi)OA]點(diǎn)擊input彈出一個(gè)div,div位置在input下方,寬度與input一致
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <style>#pop{position:absolute;border:solid 1px #000;min-height:200px;border-top:none;}</style> <input type="text" style="width:300px" onclick="showPop(this)" /> <script> function getPos(ipt) { var p = { x: 0, y: 0 }; do { p.x += ipt.offsetLeft; p.y += ipt.offsetTop; } while (ipt = ipt.offsetParent);return p } function showPop(ipt) { var pop = document.getElementById('pop'); if (!pop) { var p = getPos(ipt); pop = document.createElement('div'); pop.id = 'pop'; pop.style.cssText = 'left:' + p.x + 'px;top:' + (p.y + ipt.offsetHeight) + 'px;width:' + (ipt.offsetWidth-2) + 'px'; document.body.appendChild(pop);pop.innerHTML='<div align="right"><input type="button" onclick="this.parentNode.parentNode.style.display=\'none\'" value="關(guān)閉"/></div>'; } pop.style.display='block'; } </script> </body> </html> 效果: 該文章在 2020/1/16 11:32:00 編輯過 |
關(guān)鍵字查詢
相關(guān)文章
正在查詢... |