Home » Jquery » javascript – jquery change td text

javascript – jquery change td text

Posted by: admin February 22, 2020 Leave a comment

Questions:
<td>09 Mars 2020</td>

I have a div constructed using the above string.

the Jquery variables that I have

date1 = 09 Mars 2020
date2 = 18 Mars 2020

I just wanted to add content from another date with that date to get a result like that

<td>09 Mars 2020 - 18 Mars 2020</td>

the td that I have on the html page has nothing id nothing name nothing to value there is that the date display and I know it on a variable it misses that like looking for it to find td

<tr>
  <td>
    <table class="nobordernopadding" width="100%">
      <tbody>
        <tr>
          <td>Date prévue de livraison</td>
          <td align="right"><a href="/commande/card.php?action=editdate_livraison&amp;id=56"><span class="fa fa-pencil marginleftonly valignmiddle pictoedit" style=" color: #444;" alt="Définir la date d'expédition" title="Définir la date d'expédition"></span></a>
          </td>
        </tr>
      </tbody>
    </table>
  </td>
  <td>09 Mars 2020</td>
</tr>
How to&Answer:

Given your provided markup, one possible path for selection is:

$('.nobordernopadding')
    .closest('td')
    .next('td')
    // conditionally filter the td on the desired target text
    .filter(':contains("09 Mars 2020")')
    .text('my new value')