<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
>
<
meta
http-equiv
=
"Content-Type"
content
=
"text/html; charset=utf-8"
/>
<
title
>無標題文檔</
title
>
<
style
type
=
"text/css"
>
<!--
#apDiv1 {
border:1px solid red;
width:100px;
height:77px;
text-align:center;
padding:6px;
background-color:#FCC;
position:absolute;
z-index:99;
display:none; /*使div初始化時隱藏*/
}
input {
border:1px solid; /*注意這里的border寬度,后面要根據這個值額外增加div的left值*/
}
-->
</
style
>
<
script
type
=
"application/javascript"
src
=
"js/jquery.js"
></
script
>
<
script
type
=
"application/javascript"
>
<!--
//dom加載完成時執行
$(function(){
//input獲取焦點時在其旁邊顯示div
$('input').focus().click(function(){
var input = $(this);
var offset = input.offset();
//先后設置div的內容、位置,最后顯示出來(漸進效果)
$('#apDiv1').text(input.attr('name'))
.css('left',offset.left + input.width() + 2 + 'px')
.css('top',offset.top + 'px')
.fadeIn();
});
//input失去焦點時隱藏div
$('input').blur(function(){
$('#apDiv1').css('display','none');
});
});
//-->
</
script
>
</
head
>
<
body
>
<
div
id
=
"apDiv1"
></
div
>
<
table
width
=
"200"
border
=
"0"
cellspacing
=
"1"
cellpadding
=
"3"
>
<
tr
>
<
td
><
input
type
=
"text"
name
=
"textfield"
id
=
"textfield"
/></
td
>
<
td
><
input
type
=
"text"
name
=
"textfield2"
id
=
"textfield2"
/></
td
>
</
tr
>
</
table
>
</
body
>
</
html
>
本站僅提供存儲服務,所有內容均由用戶發布,如發現有害或侵權內容,請
點擊舉報。