Kashub's Code Barn - "djdhdhebeb"

podświetlone jako text (dodał(a) jdudjdbej @ 2023-03-27 07:46:03)

Twoja wyszukiwarka
Podświetl ten kod w:
Ostatnio dodane:
Losowe wpisy:
 
<!DOCTYPE html>
<html>
<head>
    <title>Create Material Design Table on Click</title>
 
    <!-- Import Materialize CSS -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
</head>
<body>
 
<button class="btn" onclick="createTable()">Create Table</button>
 
<div id="tableContainer"></div>
 
<script>
    function createTable() {
        var table = document.createElement('table');
        table.setAttribute('id', 'myTable');
        table.classList.add('striped');
 
        var thead = document.createElement('thead');
        var tr = document.createElement('tr');
        for (var i = 0; i < 3; i++) {
            var th = document.createElement('th');
            th.appendChild(document.createTextNode('Header ' + (i + 1)));
            tr.appendChild(th);
        }
        thead.appendChild(tr);
        table.appendChild(thead);
 
        var tbody = document.createElement('tbody');
        for (var i = 0; i < 3; i++) {
            var tr = document.createElement('tr');
            for (var j = 0; j < 3; j++) {
                var td = document.createElement('td');
                td.setAttribute('contenteditable', 'true');
                td.appendChild(document.createTextNode('Cell ' + (i + 1) + ',' + (j + 1)));
                tr.appendChild(td);
            }
            tbody.appendChild(tr);
        }
        table.appendChild(tbody);
 
        document.getElementById('tableContainer').appendChild(table);
    }
</script>
 
<!-- Import Materialize JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
 
</body>
</html>
In this code, we added the Materialize CSS and JavaScript files to the page and used the striped class to add a material design style to the table. We also added a thead and tbody element to the table and used Materialize’s btn class to style the Create Table button.
You can further customize the appearance of the table by adding additional Materialize classes or by adding custom CSS styles.
I hope this helps! Let me know if you have any questions. 😊
Odebrano wiadomość. Yes, you can make the table more material design by using a CSS framework like Materialize or by adding custom CSS styles to the table elements. Here's an example of how you can use Materialize to create a material design table: ```html <!DOCTYPE html> <html> <head> <title>Create Material Design Table on Click</title> <!-- Import Materialize CSS --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css"> </head> <body> <button class="btn" onclick="createTable()">Create Table</button> <div id="tableContainer"></div> <script> function createTable() { var table = document.createElement('table'); table.setAttribute('id', 'myTable'); table.classList.add('striped'); var thead = document.createElement('thead'); var tr = document.createElement('tr'); for (var i = 0; i < 3; i++) { var th = document.createElement('th'); th.appendChild(document.createTextNode('Header ' + (i + 1))); tr.appendChild(th); } thead.appendChild(tr); table.appendChild(thead); var tbody = document.createElement('tbody'); for (var i = 0; i < 3; i++) { var tr = document.createElement('tr'); for (var j = 0; j < 3; j++) { var td = document.createElement('td'); td.setAttribute('contenteditable', 'true'); td.appendChild(document.createTextNode('Cell ' + (i + 1) + ',' + (j + 1))); tr.appendChild(td); } tbody.appendChild(tr); } table.appendChild(tbody); document.getElementById('tableContainer').appendChild(table); } </script> <!-- Import Materialize JavaScript --> <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script> </body> </html> ``` In this code, we added the Materialize CSS and JavaScript files to the page and used the `striped` class to add a material design style to the table. We also added a `thead` and `tbody` element to the table and used Materialize's `btn` class to style the `Create Table` button. You can further customize the appearance of the table by adding additional Materialize classes or by adding custom CSS styles. I hope this helps! Let me know if you have any questions. 😊
| Opony zimowe | | Dyskretny sexshop internetowy | | Programista Trójmiasto | | Skracacz linków | | Darmowe Blogi | | Przenieś bloga z onetu | | Skracacz adresów | | Pionowe opisy |