【发布时间】:2015-05-21 22:34:56
【问题描述】:
您好,这是我在这里的第一篇文章。
我正在尝试创建一个按钮或可点击的超链接,它将导致一个聊天窗口(实时聊天支持)出现。当您单击它的按钮时会出现聊天窗口,但我也想创建一个单独的“单击此处”链接来控制它。如何更改包含多个类的 div 的类属性。我尝试了下面的代码,但对我来说不行。
$(document).ready(function(){
$("button").click(function(){
$("#jivo-label").removeClass("jivo-fixed-right jivo-animate jivo-online jivo-fade-in").addClass("jivo-fixed-right jivo-animate jivo-online");
$("#jivo-phantom").removeClass("jivo-right jivo-phantom-label jivo-notransition").addClass("jivo-right jivo-phantom-chat");
$("#jivo-chat").removeClass("jivo-animated jivo-online").addClass("jivo-animated jivo-online jivo-fade-in");
document.getElementById('jivo_chat_iframe').style.display = 'block';
document.getElementById('jivo_chat_iframe').style.visibility = 'visible';
});
【问题讨论】:
-
你不见了:
}); -
.addClass() 和 .removeClass() 应该可以解决问题。什么不适合你?
-
我不明白。您似乎正在删除类,然后立即将它们重新添加。我认为您对语法感到困惑,但不清楚您想要什么。你到底想在你的功能中完成什么?
-
向我们展示您的 HTML 代码 - 此代码没有任何意义