0
.FilterList
是所有下拉列表需要從列表中選擇一個下拉列表元素具有特定屬性值的下拉列表,並設置其選擇的價值
var $lists = $('.FilterList[ctype="' + ctype + '"]').css('display', 'inline');
有點像下面的類名工作正常,但我不知道是否有一個更簡潔有效的方法 雖然我以後更多的東西一樣,我可以代替使用的.each()
$lists.each(function() { $(this).attr('filterid') == filterid ? $(this).val(thisval) : null; });
:
$lists.first('.FilterList[filterid = "' + filterid + '"]').val(thisval);
你的意思是「每個」功能的替代品? – undefined
是的,在我的情況下可以替代.each()。 – LaserBeak