I'm using Wordpress and I need to replace a text if a tag contains a specific text. I'm not very familiar with Javascript so I hope someone here can help me :)
This is my html structure:
<tbody>
<tr class="tr1">
<td class="td1">
<a href="http://www.example.com">Name 1</a>
<strong class="quantity">× 1</strong>
</td>
<td class="td2">
<span class="span1">30$</span>
</td>
</tr>
</tbody>
What I'm trying to achieve is:
- If span class="span1" = "30$" or if span class="span1" ="40$"
- Then "Name 1" needs to be replaced by "Name 2"
- If not (= span is something else than 30 or 40), then the script must not run.
- The "Name 2" will be the same with a span = 30 or 40.
I hope my explanation is clear enough. I tried to search first by myself, I found some functions such as getelement and innerHTML but I didn't find how to combine it with the result I need.
Thank you!
EDIT: I would like to target the tag A with the specific href="http://www.example.com"