1
I’m learning JS and I set out to do an exercise. The idea is to show a specific month’s calendar on the page, and, according to the current day, pick up and print the td with Index for the day and then color the cell in the table. Unhappiness I’m not getting if you want to call the value of td.
Follow the code (ask them to ignore the mess and possible bad practices in HTML):
var agora = new Date()
var hoje = agora.getDate()
var hojeExato = hoje + 6 // Teoricamente serve para ignorar as <td> de dias da semana
var diaMes = document.getElementsByTagName("td")[hojeExato]
var res = document.getElementsByClassName(".resu")
var teste = document.getElementsByClassName(".teste1")
teste.innerText = `${diaMes}`
res.innerHTML = `${diaMes}`
<body>
<h1>Calendário de Setembro 2019 :)</h1>
<table id="tabelaEstilo">
<tr>
<td class="DOM">DOM</td> <td class="SEG">SEG</td> <td class="TER">TER</td>
<td class="QUA">QUA</td> <td class="QUI">QUI</td> <td class="SEX">SEX</td> <td class="SAB">SAB</td>
</tr>
<tr> <td>1</td> <td>2</td> <td>3</td> <td>4</td> <td>5</td> <td>6</td> <td>7</td> </tr>
<tr> <td>8</td> <td>9</td> <td>10</td> <td>11</td> <td>12</td> <td>13</td> <td>14</td> </tr>
<tr> <td>15</td> <td>16</td> <td>17</td> <td>18</td> <td>19</td> <td>20</td> <td>21</td> </tr>
<tr> <td>22</td> <td>23</td> <td>24</td> <td>25</td> <td>26</td> <td>27</td> <td>28</td> </tr>
<tr> <td>29</td> <td>30</td> <td>1</td> <td>2</td> <td>3</td> <td>4</td> <td>5</td> </tr>
<tr> <td>6</td> <td>7</td> <td>8</td> <td>9</td> <td>10</td> <td>11</td> <td>12</td> </tr>
</table>
<div class="teste1">teste</div>
<div class="resu">olá</div>
<script>
var agora = new Date()
var hoje = agora.getDate()
var hojeExato = hoje + 6 // Teoricamente serve para ignorar as <td> de dias da semana
var diaMes = document.getElementsByTagName("td")[hojeExato]
var res = document.getElementsByClassName(".resu")
var teste = document.getElementsByClassName(".teste1")
teste.innerText = `${diaMes}`
res.innerHTML = `${diaMes}`
</script>
</body>
Wesley, I don’t understand where the printing part comes in?
– Ricardo Pontual
In Divs, for testing.
– wesley pereira
I think we’re not talking about the same "print" :) to print should have something like
window.print()
, that’s not what you mean by print?– Ricardo Pontual
I mean to show on the page, in this case I use Divs as it is done in the course of CEV. Apparently I am using the incorrect term for this practice.
– wesley pereira