(function($) {
$.fn.column = function() {
var $cells = $();
this.each(function() {
var $td = $(this).closest('td, th');
if ($td.length) {
var colNum = $td[0].cellIndex + 1;
var $columnCells = $td
.closest('table')
.find('td, th')
.filter(':nth-child(' + colNum + ')');
$cells = $cells.add($columnCells);
}
});
return this.pushStack($cells);
};
})(jQuery);
cloest('td, th') 中間有 td, th 是什么意思呢?我僅僅能夠看見 cloest('td') 或者 closest('th')的用法,表示上溯一個父元素。兩個一起放在引數里,是什么意思呢?
最后的 return this.pushStack($cells); 是什么意思呢? 直接用 return $cells;不可以嗎?如果對DOM樹有影響,return $cells;會造成怎樣的影響呢?
謝謝老師
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/51618.html
標籤:JavaScript
上一篇:ActiveMQ運行一段時間后Pending Queue Size數量增加
下一篇:用th:href傳值到(/detail/{material_id}/{name}/{ty)回傳detailpage,發現樣式表無效。
