Reputation: 6663
I have the following code to update all the table cells in a specific row:
$('#riga'+id_cella).children('td').each(function(){
if (!$(this).hasClass("ore")) {
$(this).fadeOut('fast',function(){
$(this).removeClass('planned').addClass('planning');
$(this).next("a").text('Scegli');
$(this).fadeIn('fast');
});
}
});
This code change some css in each cell and should update the text of the href inside the cell to display "Scegli" instead of "solo video". The table cell has this code:
<td class="planned">
<a id="14" class="plan toPlan" href="plan.php?when=4&who=1" title="Pianifica le ore 03:00 per il gruppo 1 ">solo video</a>
</td>
The point is that next(a) seems not to select the href inside the cell. If I write:
$(this).text('Scegli');
it changes (as expected) the cell content removing the href completely. Cannot see what I am doing wrong
Upvotes: 0
Views: 68
Reputation: 14927
Change this:
$(this).next("a").text('Scegli');
to this:
$(this).find("a").text('Scegli');
See this fiddle
Or better, take advantage of chaining:
$('#riga'+id_cella).children('td').each(function(index, element){
var $ele = $(element),
noOre = !$ele.hasClass('ore');
if(noOre){
$ele.fadeOut('fast',function(){
$ele.removeClass('planned').addClass('planning').find("a").text('Scegli').end().fadeIn('fast');
});
}
});
See this fiddle for that
Upvotes: 1