利用JavaScript模擬京東快遞單號查詢效果_第1頁
利用JavaScript模擬京東快遞單號查詢效果_第2頁
利用JavaScript模擬京東快遞單號查詢效果_第3頁
利用JavaScript模擬京東快遞單號查詢效果_第4頁
利用JavaScript模擬京東快遞單號查詢效果_第5頁
已閱讀5頁,還剩2頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

第利用JavaScript模擬京東快遞單號查詢效果1、上面放大框開始是隱藏的,當(dāng)輸入單號后,就顯示,并且里面的內(nèi)容是輸入框的內(nèi)容的字體的放大

!DOCTYPEhtml

htmllang="en"

head

metacharset="UTF-8"

metahttp-equiv="X-UA-Compatible"content="IE=edge"

metaname="viewport"content="width=device-width,initial-scale=1.0"

titleDocument/title

style

table{

margin:20px;

border:none

font-size:15px;

input{

height:15px

button{

background-color:rgb(77,132,233);

border:none;

text-decoration:none;

color:white;

font-size:15px;

div{

font-size:25px;

width:100px;

height:auto;

border:1pxsolidblack;

display:none;

position:absolute;

top:0px

/style

/head

body

table

p快遞單號/p

/td

tdinputtype="text"placeholder="請輸入您的快遞單號"/td

tdbuttonahref=""查詢/a/button/td

/tr

/table

div/div

script

//當(dāng)開始在輸入框中鍵入內(nèi)容的時候,div模塊就開始顯示,里面的內(nèi)容是input里面的內(nèi)容,但字體變大

varinput=document.querySelector('input')

vardiv=document.querySelector('div')

input.addEventListener('keyup',function(){

if(input.value!=''){

div.style.display='block'

div.innerHTML=input.value

}else{

div.style.display='none'

div.innerHTML=''

/script

/body

/html

問題:

1、上面放大框的效果怎么做,倒三角雖然可以使用border來完成,但是效果會有顏色的填充

2、當(dāng)輸入框輸入的文字較多的時候,怎么自動的改變上面放大框的高度和寬度

.con::before{

content:'';

height:0;

height:0;

position:absolute;

top:28px;

left:18px;

border:8pxsolid#000;

border-style:soliddasheddashed;

border-color:#ffftransparenttransparent

}

!DOCTYPEhtml

htmllang="en"

head

metacharset="UTF-8"

metahttp-equiv="X-UA-Compatible"content="IE=edge"

metaname="viewport"content="width=device-width,initial-scale=1.0"

titleDocument/title

style

.search{

position:relative;

width:178px;

margin:100px

.con{

position:absolute;

top:-40px;

width:171px;

border:1pxsolidrgba(0,0,0,.2);

box-shadow:02px4pxrgba(0,0,0,.2);

padding:5px0;

font-size:18px;

line-height:20px;

color:#333;

display:none;

.con::before{

content:'';

height:0;

height:0;

position:absolute;

top:28px;

left:18px;

border:8pxsolid#000;

border-style:soliddasheddashed;

border-color:#ffftransparenttransparent

/style

/head

body

div

div/div

inputtype="text"placeholder="請輸入您的快遞單號"

/div

script

//當(dāng)開始在輸入框中鍵入內(nèi)容的時候,div模塊就開始顯示,里面的內(nèi)容是input里面的內(nèi)容,但字體變大

varjd=document.querySelector('.jd')

varcon=document.querySelector('.con')

jd.addEventListener('keyup',function(){//要區(qū)分keyup、keydown、keypress之間的區(qū)別

if(jd.value!=''){

con.style.display='block'

con.innerHTML=jd.value

}else{

con.style.display='none'

con.innerHTML=''

/script

/body

/html

如果換成keydown或者keypress來注冊事件的話,會少一個字,這是因為文字還沒有落入文本框的時候,就以及觸發(fā)了事件,但此時里面的內(nèi)容還是空的,因此上面的文本框是不顯示的。第二次按下的時候,立刻觸發(fā)事件,此時字并沒有進(jìn)入盒子,盒子里面留下的只有前一個字。

注意區(qū)別

keypress更加不行,因為對于功能鍵是沒有效果的。

4、當(dāng)失去焦點的時候,就隱藏con。得到焦點就顯示(onfocus、onblur)

script

//當(dāng)開始在輸入框中鍵入內(nèi)容的時候,div模塊就開始顯示,里面的內(nèi)容是input里面的內(nèi)容,但字體變大

varjd=document.querySelector('.jd')

varcon=document.querySelector('.con')

jd.addEventListener('keyup',function(){//要區(qū)分keyup、keydown、keypress之間的區(qū)別

if(jd.value!=''){

con.style.display='block'

con.innerHTML=jd.value

}else{

con.style.display='none'

con.innerHTML=''

jd.addEventListener('focus',function(){

if(jd.value!='')

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論