I’m trying to work with how our system spits out its code for a calendar and due to the formatting, I need to change the href value of some links to the value of what its children link to. Below is some sample code:
<td class="date eventDate">
<a class="dateLink" href="calendar?DATE=2012-07-06&VIEW=day">6</a>
<br>
<div>
<div class="event">
<a href="/calendar?date=20120702" class="event"></a>
<a href="/calendar?root=320794" class="eventon">6 July</a>
</div>
</div>
</td>
I need jQuery to replace the href value of the first tag with the href value of the third tag. I’m not really sure how I can get jQuery to look through all of the page’s elements to achieve this.
I think the process is look for all a.dateLink and replace the current selection with the href value of the child element a.eventon, then move on to the next a.dateLink and repeat. If there is not child element a.eventon the move on to the next.
Can anyone help me with what I need?
This code will do