gpt4 book ai didi

jquery - 添加和删​​除 ID 就像在 JQuery 中添加类一样

转载 作者:行者123 更新时间:2023-12-01 02:56:15 26 4
gpt4 key购买 nike

我有以下代码可以切换 div 上的类。我需要类似但带有 id 的东西。是用get属性完成的吗?不确定应该如何完成此操作,但它应该与下面的代码相同,因为单击的链接会更改 ID..

$('#calendar-links a').click(function(e){
e.preventDefault();
var calendar_class = $(this).attr('data-class');
$('#calendar-links a').removeClass('active');
$(this).addClass('active');
$('#aecp-calendar').removeClass('all current future events').addClass(calendar_class);
});

最佳答案

$('#calendar-links a').click(function(e){
$("#myElement").attr("id", "newId");
});

其中 newId 是元素的"new"ID。

关于jquery - 添加和删​​除 ID 就像在 JQuery 中添加类一样,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20668283/

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