Вы можете использовать метод .wrapAll()
.
$('form > input').each(function(){
$(this).next('label').andSelf().wrapAll('');
});
Если ваша разметка всегда имеет тот же порядок, я бы предпочел использовать:
var $set = $('form').children();
for(var i=0, len = $set.length; i < len; i+=2){
$set.slice(i, i+2).wrapAll('');
}
Should будет значительно быстрее.
Ref .: .wrapAll () , . andSelf () , .slice ()
Благодаря системе удаления табличного представления, когда ячейка не видна, она не загружается. Таким образом, табличное представление не будет анимировать изменение, если оно не отображается на экране.
Здесь я вижу 2 варианта:
Прокрутка до анимированной ячейки перед обновлением ее высоты
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let animatedIndexPath = ...
let visibleRows = tableView.indexPathsForVisibleRows ?? []
if visibleRows.contains(animatedIndexPath) {
self.tableView.reloadRows(at: [animatedIndexPath], with: .automatic)
} else {
UIView.animate(withDuration: 0.3, animations: {
self.tableView.scrollToRow(at: animatedIndexPath, at: .none, animated: false)
}) { _ in
self.tableView.reloadRows(at: [animatedIndexPath], with: .automatic)
}
}
}
Регулировка смещения содержимого, когда ячейка обновлено
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let animatedIndexPath = ...
let visibleRows = tableView.indexPathsForVisibleRows ?? []
if visibleRows.contains(animatedIndexPath) {
self.tableView.reloadRows(at: [animatedIndexPath], with: .automatic)
} else {
let offset = tableView.contentOffset
tableView.reloadData()
tableView.layoutIfNeeded() // forces the new offset computation
tableView.setContentOffset(offset, animated: true)
}
}
(могут возникнуть некоторые проблемы из-за динамического вычисления высоты табличного представления, отключите его tableView.estimatedRowHeight = 0
)