개발자로 가는 길(국비지원과정)/3.HTML,CSS,JavaScript, jQuery

[자바스크립트] 자바스크립트에서 table작성?

레아Leah 2022. 6. 1. 23:00
반응형

자바스크립트에서 문자열을 이용해 table테이블 만드는 방법

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
         let str = "<table border='1'>";
            str += "<tr>";
            str += "<td>1</td><td>2</td><td>3</td>";
            str += "</tr>";
            str += "</table>";

        document.write(str);    
    </script>
</head>
<body>
    
</body>
</html>
반응형