我有一个在点击 TD 中的链接时调用的函数。单击后,我将 DOM 遍历到链接所在的 TR,然后在其后创建一个新的 TR。
到现在为止还挺好。
既然我已经创建了包含 TD 的新 TR,那么现在最好引用那个新创建的 TD。或者,我是否需要遍历从原始单击对象创建的新 TD?
$("td.expandable a").click(function(){
// figure out the number of columns we need to span
var colspan;
colspan = $(this).parents("tr").children("td").size();
// insert the new TR
$(this).parents("tr").after("<tr><td colspan=' & colspan & '></td></tr>");
// **what syntax would I use here to refer to the above made TD?**
return false;
});