0
이 코드가 효과적이지 않은 이유를 알 수 없습니다. 내가 도대체 뭘 잘못하고있는 겁니까? Javascript로 표를 만들려면 document.write
을 사용해야합니다. 어떤 도움을 주시면 감사하겠습니다! 당신이 document.write
의 전체 귀를 가지고 지금자바 스크립트에서 document.write와 함께 HTML 표를 표시하려고 시도합니다.
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript">
var rows;
var cols;
function table(rows, cols){
document.write('<table border="1">');
for (i=0, i < rows, i++){
document.write('<tr>');
for (j=0, j < cols, j++) {
document.write('<td>' + 'cell' + '</td>');
}
document.write('</tr>');
}
document.write('</table>');
}
document.write (table(2, 4));
</script>
</body>
</html>
는 document.write''사용하지 마십시오! 왜 쉼표를 사용하고 있습니까?! 왜 당신은'정의되지 않은 '것을 쓰고 있습니까? – Li357
브라우저 dev 도구 콘솔의 오류를보고 시작하십시오. 당신은 논리 문제를 가지고 있지만 콘솔이 당신에게 가리킬 문법 문제도 있습니다. – charlietfl
'document.write();를 사용하지 않는 것이 좋습니다. 그러나 이것이 작동하지 않는 이유는'for()'루프 때문입니다. ','를';'example 'i = 0;로 대체하십시오. i <행; i ++' – NewToJS