jQuery交换<;TD>;每秒钟<;TR>;(第n个孩子)
如何在每行交换TD的“课程文本”和“课程日期”?我想显示一个包含五个自定义帖子的过滤器,但在每一行上,这两个帖子必须交换jQuery交换<;TD>;每秒钟<;TR>;(第n个孩子),jquery,html-table,css-selectors,swap,Jquery,Html Table,Css Selectors,Swap,如何在每行交换TD的“课程文本”和“课程日期”?我想显示一个包含五个自定义帖子的过滤器,但在每一行上,这两个帖子必须交换 <table class="course"> <tr> <td class="course_text"> <a href="<?php the_permalink(); ?>"><h3 class="course_title"><?php the_title(); ?>
<table class="course">
<tr>
<td class="course_text">
<a href="<?php the_permalink(); ?>"><h3 class="course_title"><?php the_title(); ?></h3></a><br />
<div class="course_excerpt"><?php the_excerpt(); ?></div>
</td>
<td class="course_date">
<?php
$dateformatstring_day = "l";
$dateformatstring_month = "d";
$dateformatstring_year = "F";
$unixtimestamp = strtotime(get_field('cursusdatum'));
echo '<div class="course_day">';
echo date_i18n($dateformatstring_day, $unixtimestamp);
echo '</div><br />';
echo '<div class="course_month">';
echo date_i18n($dateformatstring_month, $unixtimestamp);
echo '</div><br />';
echo '<div class="course_year">';
echo date_i18n($dateformatstring_year, $unixtimestamp);
echo '</div>';
?>
</td>
</tr>
</table>
您可以尝试类似的方法-
$('td.course_date').each(function(){
var $tr = $(this).closest('tr');
$(this).prependTo($tr);
});
这真是太好了!但是,它在每一家银行都进行互换。如何使其仅附加到第二个和第四个?