Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Modify table text

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #240882
    triplebit
    Participant

    Her is my html
    I want to refer to the italic text (target-text) and change it(and only that) to something else like “new-text”.
    Is it possible with jQuery?
    Thx
    I. Lesher

    <tr class="odd">
    <td>monthly recurring</td>
    <td>
    <strong>ILS 50.00</strong> target-text<strong>ILS 50.00 לפי חודש עבור 12 חודשים נוסף</strong>. </td>
    <td>
    <a href="http://triplebit.com/kityopo/membership-account/membership-checkout/?level=5">בחר</a>
    </td>
    </tr>
    
    #240883
    Shikkediel
    Participant

    Not really clear what’s italic exactly and how that’s done. Are you using &lt;i&gt;&lt;/i&gt; tags?

    #241423
    Mottie
    Member

    Since nothing is wrapping the text you want to replace, it might be easiest to use a combination of jQuery and plain JS (demo)

    $('.target-cell')
        .find('strong')[0]
        .nextSibling.textContent = "new-text";
    

    This method does not allow you to add new HTML.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.