gpt4 book ai didi

jQuery 更改多个属性或替换整个 html

转载 作者:行者123 更新时间:2023-12-03 21:40:05 26 4
gpt4 key购买 nike

我想知道使用 jQuery 更改多个属性是否更有效/更快,或者只是一次性更改替换所有 html。这是我目前正在使用的代码。

// shows the table and changes the image to up
showTable = function(tableId){
$('#img' + tableId).attr("src", images["up"]).attr("alt", "Hide Table").attr("title", "Hide Table");
$('#' + tableId).fadeIn(250);
}

或者这样会更快吗?

// shows the table and changes the image to up
showTable = function(tableId){
$('#img' + tableId).replaceWith('some html');
$('#' + tableId).fadeIn(250);
}

最佳答案

$('#greatphoto').attr({
alt: 'Beijing Brush Seller',
title: 'photo by Kelly Clark'
});

示例取自 jQuery Documentation .

关于jQuery 更改多个属性或替换整个 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5151874/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com