1、html部分

1 <!--指定元素--> 2 <div id="div1" style="margin: 500px 0px 0px 500px; width: 200px;"><input type="text" name="Name" /></div> 3 <!--顯示面板--> 4 <div id="Pannel" style="display: none; position: absolute; border: 1px solid #e1e1e1;"> 5 <h1>內容部分</h1> 6 </div>
2、js部分

1 $("input[name='Name']").on("click", function () { 2 //獲取當前元素 3 var elem = $(this); 4 var tops = elem.offset().top + elem[0].offsetHeight; 5 //設置當前元素的寬、距離瀏覽器頂部、距離瀏覽器左邊 6 $("#Pannel").css({ 7 width: (elem[0].offsetWidth + 50) + "px", 8 height:'200px', 9 top: tops + "px", 10 left: elem.offset().left + "px" 11 }).show(); 12 });