我想點(diǎn)擊按鈕,改變<p>標(biāo)簽內(nèi)的文本內(nèi)容,可是總是提示:Uncaught TypeError: Cannot read property 'nodeValue' of undefined/////////html///////////
<input?type="text"?name="email"?id="email"?placeholder="請輸入郵箱">
<button?id="check-email">郵箱格式是否符合</button>
<div?class="email-result">請點(diǎn)擊查詢</div>
/////////////js////////////
function?isEmail(emailStr)?{
????var?emailResult?=?document.getElementsByClassName("email-result");
console.log(typeof?emailResult)????????????//這里輸出object
console.log(emailResult.firstChild.nodeValue)?????//未定義
emailResult.firstChild.nodeValue?=?"finish?your?implement";????????//未定義
}
為什么這個(gè)javascript函數(shù)提示text類型的nodeValue為undefined?
newsudhc3634140
2016-09-20 01:45:36