测试页面如下:
- <!DOCTYPE html>
- <html>
- <head>
- <title>InputPostion</title>
- <script type="text/javascript" src="kingwolfofsky.js""></script>
- <script type="text/javascript">
- function show(elem) {
- var p = kingwolfofsky.getInputPositon(elem);
- var s = document.getElementById('show');
- s.style.top = p.bottom+'px';
- s.style.left = p.left + 'px';
- s.style.display = 'inherit';
- }
- </script>
- </head>
- <body>
- <textarea id="text" onkeyup="show(this)" style="width: 340px; height: 210px;"></textarea>
- <br />
- <input type="text" onkeyup="show(this)" style="width: 340px;" />
- <div id="show" style="width: 34px; height: 13px; background: #eee; position: absolute;border:1px solid grey;font-size:13px; display:none;">Tips</div>
- </body>
- </html>