TamperMonkey: add element after content in a <td> without IDs

3945 views javascript
8

To clarify, I wish to add a left facing arrow to the right side of a link that is inside of a <td> (or rather to all the <td> in that column). The arrow will later be used for an accordion dropdown menu.

First, what method can I use to insert <a class="accordion">&#9664;</a>? (pure JS if possible) And how can I have it place that on EVERY <td> that contains the barcode number but not cells that contain other links like shipIDs?

http://jsfiddle.net/pshock13/fotr5p93/

    <table>
  <thead>
    <tr class="header">
      <th class="tablesorter-header">Shipment ID</th>
      <th class="tablesorter-header">Barcode</th>
      <th class="tablesorter-header"> More info</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a href="http://search.com/AAA/results?s=7546895555555">7546895555555</a></td>
      <td><a href="http://search.com/AAA/results?s=987654321">987654321</a></td>
      <td>more stuff</td>
    </tr>
    <tr>
      <td><a href="http://search.com/AAA/results?s=1234567222222">1234567222222</a></td>
      <td><a href="http://search.com/AAA/results?s=123456789">123456789</a></td>
      <td>other stuff</td>
    </tr>
  </tbody>
</table>

in the JSFiddle is a stripped down version of what I'm working with. there are no IDs to work with and any classes used are also used on other elements that have links as well.

answered question

1 Answer

8

I read your Blog And I understand this blog. this blog helfully scotland email lists. i like this blog.

posted this

Have an answer?

JD

Please login first before posting an answer.