最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

Cannot read property 'childNodes' of null,清除數(shù)據(jù)的時(shí)候,下面沒(méi)有子節(jié)點(diǎn)。

<%--
??Created?by?IntelliJ?IDEA.
??User:?kiss
??Date:?2018/8/9
??Time:?10:54
??To?change?this?template?use?File?|?Settings?|?File?Templates.
--%>
<%@?page?contentType="text/html;charset=UTF-8"?language="java"?%>
<html>
??<head>
????<title>百度一下</title>
????<style>
??????.baidu{
????????position:?absolute;
????????top:?50%;
????????left:?50%;
????????margin-left:?-150px;
????????margin-top:?-100px;
??????}
??????.mouseover{

??????}
??????.mouseout{

??????}
????</style>
????<script>
??????var?xmlHttp;
??????function?bdinput()?{
??????????var?baduinput?=?document.getElementById("baidu");
??????????if(baduinput.value?==?""){
??????????????return;
??????????}
??????????xmlHttp?=?createXMLHTTP();
??????????var?url?=?"search?keyword="+escape(baduinput.value);
??????????//true表示js腳本在send()方法之后繼續(xù)執(zhí)行,而不會(huì)等待服務(wù)器響應(yīng)
??????????xmlHttp.open("GET",url,true);
??????????//xmlHttp的狀態(tài)碼0-4,4表示完成
??????????xmlHttp.onreadystatechange?=?callback;
??????????xmlHttp.send(null);
??????}
??????//創(chuàng)建xmlHttp對(duì)象
??????function?createXMLHTTP()?{
??????????var?xmlhttp;
??????????//大多數(shù)瀏覽器適應(yīng)
??????????if(window.XMLHttpRequest){
??????????????xmlhttp?=?new?XMLHttpRequest();
??????????}
??????????//考慮瀏覽器兼容問(wèn)題
??????????if(window.ActiveXObject){
??????????????xmlhttp?=?new?ActiveXObject("Microsoft.XMLHTTP");
??????????????if(!xmlhttp){
??????????????????xmlhttp?=?new?ActiveXObject("Msxml2.XMLHTTP");
??????????????}
??????????}
??????????return?xmlhttp;
??????}
??????//回調(diào)函數(shù)
??????function?callback()?{
??????????if(xmlHttp.readyState?==?4){
??????????????if(xmlHttp.status?==?200){
??????????????????//接受返回的文本
??????????????????var?result?=?xmlHttp.responseText;
??????????????????//解析數(shù)據(jù)
??????????????????var?json?=?eval("("+result+")");
??????????????????//展示在input款下面
??????????????????console.log(result);
??????????????????console.log(eval("("+result+")"));
??????????????????setContent(json);
??????????????}
??????????}
??????}
??????//數(shù)據(jù)的展示
??????function?setContent(baduinput)?{
??????????clearContent();
??????????var?size?=?baduinput.length;
??????????for?(var?i?=?0;?i?<?size?;?i++)?{
??????????????var?nextnode?=?baduinput[i];//代表json格式數(shù)據(jù)的第幾個(gè)元素
??????????????var?tr?=?document.createElement("tr");
??????????????var?td?=?document.createElement("td");
??????????????td.setAttribute("border","0");
??????????????td.setAttribute("bgcolor","#fffafa");
??????????????td.onmouseover?=?function?(ev)?{
??????????????????this.className?=?"mouseover";
??????????????}
??????????????td.onmouseout?=?function?(ev)?{
??????????????????this.className?=?"mouseover";
??????????????}
??????????????td.onclick?=?function?(ev)?{

??????????????}
??????????????var?text?=?document.createTextNode(nextnode);
??????????????td.appendChild(text);
??????????????tr.appendChild(td);
??????????????document.getElementById("table-tbody").appendChild(tr);
??????????}
??????}
??????//清除輸入框下面的數(shù)據(jù)
??????function?clearContent()?{
??????????var?table_tbody?=??document.getElementById("table_tbody");
??????????var?size?=?table_tbody.childNodes.length;
??????????console.log(size);
??????????for?(var?i?=?size-1;?i?>=?0;?i--)?{
??????????????table_tbody.removeChild(table_tbody.childNodes[i]);
??????????}
??????}
????</script>
??</head>
??<body>
??<div?class="baidu">
????<input?type="text"?width="300px"?height="100px"?onkeyup="bdinput();"?id="baidu">
????<input?type="button"?value="百度一下">
????<div?id="popdiv">
??????<table?id="content-table"?bgcolor="#fffafa"?border="0"?cellspacing="0"?cellpadding="0">
????????<tbody?id="table-tbody">

????????</tbody>
??????</table>
????</div>
??</div>
??</body>
</html>
在數(shù)據(jù)展示前調(diào)用clearContent(),確實(shí)<tbody?id="table-tbody">下面沒(méi)有子節(jié)點(diǎn),清除數(shù)據(jù)應(yīng)該在哪里調(diào)用???


正在回答

1 回答

function?clearContent()?{
??????????var?table_tbody?=??document.getElementById("table_tbody");
??????????var?size?=?table_tbody.childNodes.length;
??????????console.log(size);
??????????for?(var?i?=?size-1;?i?>=?0;?i--)?{
??????????????table_tbody.removeChild(table_tbody.childNodes[i]);
??????????}
??????????document.getElement("popDiv").style.border="none";
??????}


0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

Cannot read property 'childNodes' of null,清除數(shù)據(jù)的時(shí)候,下面沒(méi)有子節(jié)點(diǎn)。

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)