JSFiddle - React, Tailwind, and code Playground

by Verdi Kapuku

HTML

<body>

    <div class="navigation">
                <div id="forrige">
                    <a href="november.html">Forrige måned</a>
                </div>

                <div id="naeste">
                    <a href="januar.html">Næste måned</a>
                </div>
            </div>

    <br><br>

    <table class="ugedage">
                <tr>
                    <th>Mandag</th>
                    <th>Tirsdag</th>
                    <th>Onsdag</th>
                    <th>Torsdag</th>
                    <th>Fredag</th>
                    <th>Lørdag</th>
                    <th>Søndag</th>
                </tr>
                    <tr>
                        <td class="grayedout" data-href="#"><p>28</p></td>
                        <td class="grayedout" data-href="#"><p>29</p></td>
                        <td class="grayedout" data-href="#"><p>30</p></td>
                        <td class="dato" data-href="#">1</td>
                        <td class="dato" data-href="#">2</td>
                        <td class="dato" data-href="#">3</td>
                        <td class="dato" data-href="#">4</td>
                    </tr>
                    <tr>
                        <td class="dato" data-href="#">5</td>
                        <td class="dato" data-href="#">6</td>
                        <td class="dato" data-href="#">7</td>
                        <td class="dato" data-href="#">8</td>
                        <td class="dato" data-href="#">9</td>
                        <td class="dato" data-href="#">10</td>
                        <td class="dato" data-href="#">11</td>
                    </tr>
                    <tr>
                        <td class="dato" data-href="#">12</td>
                        <td class="dato" data-href="#">13</td>
                        <td class="dato" data-href="#">14</td>
                        <td class="dato" data-href="#">15</td>
                        <td class="dato" data-href="#">16</td>
              ...

CSS

.ugedage {
    width: 95%;
    margin-left: 2.5%;
    margin-right: 2.5%;
}

.ugedage th {
    border: 1px solid;
    padding: 20px;
    border-radius: 4px;
}

.ugedage td {
    border: 1px solid;
    border-radius: 4px;
    padding: 20px;
    padding-top: 0px;
    padding-right: 5px;
    padding-bottom: 10px;
    padding-left: 10px;
    text-align: right;
}

.grayedout {
    background-color: #d3d3d3;
    font-size: 12;
}

.dato {
    color: black;
    font-size: 12;
    text-decoration: none;
}

td a {
    display:block;
    width:100%;
    height: 100%;
}

.grayedout p {
    color: gray;
    font-size: 12;
    text-decoration: none;
}

#forrige {
    float: left;
    margin-left: 1%;
}

#naeste {
    float: right;
    margin-right: 1%;
}

table td[data-href] {
        cursor: pointer;
    }

JavaScript

let row = $('tr');
row.each((index,row) =>{ // For each row

    if(index !== 0) return; // We only want 1 entry of!

    $('td').each((index,day) => { // For each day
        if($(day).hasClass('grayedout')) return; // Skip grayed out days

        $(day).on('click',addApointment); // The part we care about
    });
})

function addApointment() {
    let dayNum = $(this).text();
    let appointment = prompt(`What would you like to add for an appointment for the ${dayNum}th?`);
}