我想点击按钮,改变<p>标签内的文本内容,可是总是提示:
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">请点击查询</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"; //未定义 }
stone310