0
$(function() {
$max = 4;
$i = 1;
for ($i = 1; $i < 3; $i++) {
$('#itemListLeading table tr :nth-child(' + $i + ')').each(function() {
$length = $(this).children().text().length;
if ($length > $max) {
$max = $length;
}
$('#itemListLeading table tr :nth-child(' + $i ' +)').promise().done(function() {
$(this).css("min-width", $max * 8 + "px");
});
});
};
});
不確定爲什麼這裏不起作用。我試圖通過'1'和'2',也許更多後來到第n個孩子()。它適用於單個孩子(1),即。沒有for循環。還是有更好的方法來傳遞x個變量來運行函數?For loop將變量傳遞到函數上
http://jsfiddle.net/xNquz/7/鏈接在這裏,因爲它不會讓我張貼。 – Supernal 2013-04-29 13:41:21
JavaScript不是PHP;你的變量名不會以'$'開頭。 – 2013-04-29 13:43:36
你還沒有真正解釋問題是什麼。 – 2013-04-29 13:44:13