I have this function and the second this needs to refer not to the line before it but to the first line of the function:
$('.externallink').each(function() {
var $externallink = $(this).html();
if ($externallink.length > 0) {
$(this).closest('tr').children('.filter').append('<p> test</p>');
}
});
So the first (this).html() refers to the ('.externallink').each(function().
The second (this).closest('tr') I want to also refer to the first ('.externallink').each(function(), but I have a feeling it’s referring to the ($externallink.length > 0) that is right above it.
There are multiple rows in this table so I need to make sure that ('.filter') classes that this is being appended to is only the one that’s in the same row as the .externallink in the question.
<tr>
<td style="width: 35%">
<a class="filter" href="#">March</a>
</td>
<td class="year" style="width: 20%">2010</td>
<td class="externallink" style="display:none">http://www.google.com/</td>
</tr>
thisis perfectly fine and referring to .externallink.I don’t think there is any function called
childin jQuery, usechildreninsteadChange your code to:
If you can post HTML the navigation to .filter can be validated as well.