每日一練 30天JS挑戰 實時搜尋列表

2021-10-24 20:54:51 字數 1973 閱讀 7478

lang

="en"

>

>

charset

="utf-8"

>

>

type ahead ?title

>

rel=

"stylesheet"

href

="style.css"

>

head

>

>

class

="search-form"

>

type

="text"

class

="search"

placeholder

="city or state"

>

class

="suggestions"

>

>

filter for a cityli

>

>

or a stateli

>

ul>

form

>

>

const endpoint =

'';//1獲取資料

const citeies =

;//fetch方法

// fetch(endpoint)

// .then(resolve=>resolve.json())

// .then(data=>citeies.push(...data));

//async/await

//async和await方法封裝原生ajax

const p =

newpromise

((resolve,reject)

=>

else}}

});async

function

get_data

(url, arr)

catch

(e)}

//同步形式呼叫非同步

get_data

(endpoint,citeies)

;//2篩選資料

function

findmatches

(wordstomatch,citeies))}

//顯示資料

function

displaymatches()

`);const statename = place.state.

replace

(regexp

(this

.value,

'gi'),

`$`)

;return

` $,$$`

}).join(''

);//去除陣列的都好,轉換成字串

suggestions.innerhtml = html;

}//逗號分隔數字

function

numberwithcommas

(x))+(?!\d))/g

,',');

}const searchinput = document.

queryselector

('.search');

const suggestions = document.

queryselector

('.suggestions');

searchinput.

addeventlistener

('change'

,displaymatches)

; searchinput.

addeventlistener

('keyup'

,displaymatches)

;script

>

body

>

html

>

每日一練 JS30天挑戰 JS變數的賦值和引用

lang en charset utf 8 js reference vs copytitle head let name arvin let name2 name console.log name,name2 arvin arvin name 蘋果 console.log name,name2 蘋...

每日一練4

員工表emp 員工編號eid,姓名ename,工作職位title,僱傭日期hiretime,工資salary,獎金bonus,部門depart 部門表dept 部門編號did,名稱dname,部門領導leader 員工資料 1001,張三 銷售 1999 12 1 3000.0,1100.0,102...

每日一練25

請描述 mysql 從安裝到配置的全部詳細過程 確保一台新電腦可以順利使用 mysql mysql安裝嚮導啟動,按 next 繼續 選擇安裝型別,有 typical 預設 complete 完全 custom 使用者自定義 三個選項,我們選擇 custom 有更多的選項,也方便熟悉安裝過程 選擇配置...