RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题 / 1596652
Accepted
Alexey
Alexey
Asked:2024-10-14 15:21:36 +0000 UTC2024-10-14 15:21:36 +0000 UTC 2024-10-14 15:21:36 +0000 UTC

该类挂在错误的元素上

  • 772

我的html代码:

document.querySelector(".instruction").addEventListener("click", function(object) {
    const plus = object.target.closest('.decription-open');
    const description = $('.instruction-decription')
    if (plus) {
        plus.classList.toggle('decription-open-true');
        if(description.classList = plus.classList){
            description.classList.toggle('decription-true');
        }
    }
})
/**/
.about-service {
    width: 100%;
    padding-top: 100px;
    padding-bottom: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #3F80FF;
}
.about-service-content {
    width: 1400px;
    padding-right: 30px;
    padding-left: 30px;
    justify-content: space-between;
    align-items: start;
    display: flex;
}
.about-service-content .basic-left h1 {
    width: 475px;
    font-family: AcherusFeral;
    font-style: normal;
    font-weight: 700;
    font-size: 65px;
    color: #FFFFFF;
}
.about-service-content .basic-left p {
    margin-top: 20px;
    width: 450px;
    font-family: Inter;
    font-style: normal;
    font-weight: 400;
    font-size: 20px;
    color: #FFFFFF;
}
.about-service-content .basic-left button {
    margin-top: 20px;
    padding-left: 70px !important;
    padding-right: 70px !important;
    padding: 18px;
    cursor: pointer;
    background: #EE9D23;
    font-family: AcherusFeral;
    font-style: normal;
    font-weight: 400;
    font-size: 25px;
    color: #FFFFFF;
    border: 0;
    border-radius: 10px;
}
.about-service-content .basic-right .instruction {
    list-style-type: none;
}
.about-service-content .basic-right .instruction h1 {
    font-family: AcherusFeral;
    font-style: normal;
    font-weight: 400;
    font-size: 30px;
    color: #FFFFFF;
}
.about-service-content .basic-right .instruction h1:nth-child(2) {
    margin-left: 10px;
    width: 400px;
}
.about-service-content .basic-right .instruction li span {
    align-items: start;
    justify-content: end;
    display: flex;
}
.about-service-content .basic-right .instruction li span:nth-child(2) {
    display: none;
}
.decription-true {
    width: max-content;
    margin-left: auto;
    margin-right: 30px;
    display: flex !important;
}
.about-service-content .basic-right .instruction li span a{
    transition: 0.2s;
    cursor: pointer;
    height: 30px;
    position: relative;
    margin-top: auto;
    margin-bottom: auto;
}
.about-service-content .basic-right .instruction li span p{
    width: 400px;
    margin-top: 10px;
    font-family: Inter;
    font-style: normal;
    font-weight: 400;
    font-size: 20px;
    color: #FFFFFF;
}
.about-service-content .basic-right .instruction li {
    transition: 0.2s;
    margin-top: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #FFF;
}
.about-service-content .basic-right .instruction li:first-child {
    margin-top: 0px;
}
.decription-open-true {
    rotate: 135deg;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<div class="about-service">
        <div class="about-service-content">
            <div class="basic-left">
                <h1>Как работает сервис?</h1>
                <p>Легко, максимально прост и удобен в использование!</p>
                <button>Мои заметки</button>
            </div>
            <div class="basic-right">
                <ul class="instruction">
                    <li>
                        <span>
                            <h1>1.</h1>
                            <h1>Войдите в аккаунт или создайте его</h1>
                            <a class="decription-open decription-one">
                                <svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
                                    <path d="M13.75 13.75V6.25H16.25V13.75H23.75V16.25H16.25V23.75H13.75V16.25H6.25V13.75H13.75Z" fill="#10F09F"/>
                                </svg>
                            </a>                              
                        </span>
                        <span class="instruction-decription decription-one">
                            <p>Чтобы воспользоваться сервисом Вам нужно зарегистрировать аккаунт, если у вас его еще нет.</p>
                        </span>
                    </li>
                    <li>
                        <span>
                            <h1>2.</h1>
                            <h1>Перейдите в раздел с заметками</h1>
                            <a class="decription-open decription-two">
                                <svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
                                    <path d="M13.75 13.75V6.25H16.25V13.75H23.75V16.25H16.25V23.75H13.75V16.25H6.25V13.75H13.75Z" fill="#10F09F"/>
                                </svg>
                            </a>                              
                        </span>
                        <span class="instruction-decription decription-two">
                            <p>Войдите в личный кабинет и нажмите на кнопку "Мои заметки"</p>
                        </span>
                    </li>
                    <li>
                        <span>
                            <h1>3.</h1>
                            <h1>Отредактируйте заметку если потребуется</h1>
                            <a class="decription-open decription-three">
                                <svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
                                    <path d="M13.75 13.75V6.25H16.25V13.75H23.75V16.25H16.25V23.75H13.75V16.25H6.25V13.75H13.75Z" fill="#10F09F"/>
                                </svg>
                            </a>                              
                        </span>
                        <span class="instruction-decription decription-three">
                            <p>С каждой созданной заметкой можно работать отдельно, изменяйте ее или выделяйте среди остальных!</p>
                        </span>
                    </li>
                </ul>  
            </div>
        </div>
    </div>

问题在于,应该挂在带有“指令描述”类的跨度上的类挂在超链接上

javascript
  • 1 1 个回答
  • 30 Views

1 个回答

  • Voted
  1. Best Answer
    ksa
    2024-10-14T16:59:49Z2024-10-14T16:59:49Z

    问题在于,应该挂在带有“指令描述”类的跨度上的类挂在超链接上

    这是你想要的效果吗?让文字显示和隐藏?

    document.querySelector(".instruction").addEventListener("click", function(object) {
      const plus = object.target.closest('.decription-open');
      if (!plus) return
      const description = plus.closest('li').querySelector('.instruction-decription')
      plus.classList.toggle('decription-open-true');
      description.classList.toggle('decription-true');
    })
    /**/
    
    .about-service {
      width: 100%;
      padding-top: 100px;
      padding-bottom: 100px;
      display: flex;
      align-items: center;
      justify-content: center;
      background-color: #3F80FF;
    }
    
    .about-service-content {
      width: 1400px;
      padding-right: 30px;
      padding-left: 30px;
      justify-content: space-between;
      align-items: start;
      display: flex;
    }
    
    .about-service-content .basic-left h1 {
      width: 475px;
      font-family: AcherusFeral;
      font-style: normal;
      font-weight: 700;
      font-size: 65px;
      color: #FFFFFF;
    }
    
    .about-service-content .basic-left p {
      margin-top: 20px;
      width: 450px;
      font-family: Inter;
      font-style: normal;
      font-weight: 400;
      font-size: 20px;
      color: #FFFFFF;
    }
    
    .about-service-content .basic-left button {
      margin-top: 20px;
      padding-left: 70px !important;
      padding-right: 70px !important;
      padding: 18px;
      cursor: pointer;
      background: #EE9D23;
      font-family: AcherusFeral;
      font-style: normal;
      font-weight: 400;
      font-size: 25px;
      color: #FFFFFF;
      border: 0;
      border-radius: 10px;
    }
    
    .about-service-content .basic-right .instruction {
      list-style-type: none;
    }
    
    .about-service-content .basic-right .instruction h1 {
      font-family: AcherusFeral;
      font-style: normal;
      font-weight: 400;
      font-size: 30px;
      color: #FFFFFF;
    }
    
    .about-service-content .basic-right .instruction h1:nth-child(2) {
      margin-left: 10px;
      width: 400px;
    }
    
    .about-service-content .basic-right .instruction li span {
      align-items: start;
      justify-content: end;
      display: flex;
    }
    
    .about-service-content .basic-right .instruction li span:nth-child(2) {
      display: none;
    }
    
    .decription-true {
      width: max-content;
      margin-left: auto;
      margin-right: 30px;
      display: flex !important;
    }
    
    .about-service-content .basic-right .instruction li span a {
      transition: 0.2s;
      cursor: pointer;
      height: 30px;
      position: relative;
      margin-top: auto;
      margin-bottom: auto;
    }
    
    .about-service-content .basic-right .instruction li span p {
      width: 400px;
      margin-top: 10px;
      font-family: Inter;
      font-style: normal;
      font-weight: 400;
      font-size: 20px;
      color: #FFFFFF;
    }
    
    .about-service-content .basic-right .instruction li {
      transition: 0.2s;
      margin-top: 20px;
      padding-bottom: 10px;
      border-bottom: 1px solid #FFF;
    }
    
    .about-service-content .basic-right .instruction li:first-child {
      margin-top: 0px;
    }
    
    .decription-open-true {
      rotate: 135deg;
    }
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
    <div class="about-service">
            <div class="about-service-content">
                <div class="basic-left">
                    <h1>Как работает сервис?</h1>
                    <p>Легко, максимально прост и удобен в использование!</p>
                    <button>Мои заметки</button>
                </div>
                <div class="basic-right">
                    <ul class="instruction">
                        <li>
                            <span>
                                <h1>1.</h1>
                                <h1>Войдите в аккаунт или создайте его</h1>
                                <a class="decription-open decription-one">
                                    <svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
                                        <path d="M13.75 13.75V6.25H16.25V13.75H23.75V16.25H16.25V23.75H13.75V16.25H6.25V13.75H13.75Z" fill="#10F09F"/>
                                    </svg>
                                </a>                              
                            </span>
                            <span class="instruction-decription decription-one">
                                <p>Чтобы воспользоваться сервисом Вам нужно зарегистрировать аккаунт, если у вас его еще нет.</p>
                            </span>
                        </li>
                        <li>
                            <span>
                                <h1>2.</h1>
                                <h1>Перейдите в раздел с заметками</h1>
                                <a class="decription-open decription-two">
                                    <svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
                                        <path d="M13.75 13.75V6.25H16.25V13.75H23.75V16.25H16.25V23.75H13.75V16.25H6.25V13.75H13.75Z" fill="#10F09F"/>
                                    </svg>
                                </a>                              
                            </span>
                            <span class="instruction-decription decription-two">
                                <p>Войдите в личный кабинет и нажмите на кнопку "Мои заметки"</p>
                            </span>
                        </li>
                        <li>
                            <span>
                                <h1>3.</h1>
                                <h1>Отредактируйте заметку если потребуется</h1>
                                <a class="decription-open decription-three">
                                    <svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
                                        <path d="M13.75 13.75V6.25H16.25V13.75H23.75V16.25H16.25V23.75H13.75V16.25H6.25V13.75H13.75Z" fill="#10F09F"/>
                                    </svg>
                                </a>                              
                            </span>
                            <span class="instruction-decription decription-three">
                                <p>С каждой созданной заметкой можно работать отдельно, изменяйте ее или выделяйте среди остальных!</p>
                            </span>
                        </li>
                    </ul>  
                </div>
            </div>
        </div>

    • 0

相关问题

  • 第二个 Instagram 按钮的 CSS 属性

  • 由于模糊,内容不可见

  • 弹出队列。消息显示不正确

  • 是否可以在 for 循环中插入提示?

  • 如何将 JSON 请求中的信息输出到数据表 Vuetify vue.js?

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5