添加删除课程? [英] Add remove class?

查看:91
本文介绍了添加删除课程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我有两个类用于两个链接和两个具有不同信息的div.我想做的是拥有它,因此,当您单击一个链接时,它将为两个类都添加一个2,并使第二个div可见.当您点击另一个链接时,该链接取2,使第一个div可见.

Okay I have two classes for two links and two divs with different information. What I am trying to do is have it so when you click on one link it adds a 2 to both of the classes and makes the second div visable. When you click on the other link it takes off a 2 and makes the first div visable.

这是我目前得到的

$("#posts").click(function () {
    $("#sideboxtopleft").toggleClass("2");
    $("#arrow").toggleClass("2");
});

当您单击链接时,链接是很多帖子.它将生成sideboxtopleft和arrow,sideboxtopleft2和arrow2,并且当您单击注释时,将同时删除这两个.然后有两个div,一个设置为隐藏,我要使其可见,另一个设置为隐藏.几乎可以通过更改选项卡类来创建选项卡系统.

Pretty much posts is the link, when when you click on it. It would make sideboxtopleft and arrow, sideboxtopleft2 and arrow2 and when you clicked on comments it would take off the 2 of both of those. Then there are two divs, one is set to hidden and I want to make it visable and set the other to hidden. Pretty much creating a tab system with changing tab classes.

推荐答案

toggleClass添加或删除新类,它不只是附加字符串.

toggleClass adds or removes a new class, it doesn't just append the string.

可能的解决方案是执行以下操作:

A potential solution would be to do the following:

$("#posts").click(function () {
    $("#sideboxtopleft").toggleClass("sideboxtopleft").toggleClass("sideboxtopleft2");
    $("#arrow").toggleClass("arrow").toggleClass("arrow2");
});

这篇关于添加删除课程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆