zoukankan      html  css  js  c++  java
  • jquery: siblings使用删除当前样式,添加所有siblings样式

    html:

    <div class="hot-purchase">
                        <div class="title">热门团购</div>
                        <dl class="item on">
                            <dt>
                                <a href="" class="text-area">[text]</a>
                                <a href="" class="text-name">title</a>
                                <span class="price">13000</span>
                            </dt>
                            <dd class="tag-1">
                                <span class="tag">title</span>
                                <span class="description">test</span>
                            </dd>
                            <dd class="tag-2 clearfix">
                                <div class="picture-left fl">
                                    <a href=""><img src="../images/consult_hot_purchase.jpg" alt=""></a>
                                </div>
                                <div class="content-right fl">
                                    <p>description</p>
                                    <a href="">link</a>
                                </div>
                            </dd>
                        </dl>
                        <dl class="item">
                            <dt>
                                <a href="" class="text-area">[text]</a>
                                <a href="" class="text-name">title</a>
                                <span class="price">13000</span>
                            </dt>
                            <dd class="tag-1">
                                <span class="tag">title</span>
                                <span class="description">test</span>
                            </dd>
                            <dd class="tag-2 clearfix">
                                <div class="picture-left fl">
                                    <a href=""><img src="../images/consult_hot_purchase.jpg" alt=""></a>
                                </div>
                                <div class="content-right fl">
                                    <p>description</p>
                                    <a href="">link</a>
                                </div>
                            </dd>
                        </dl>
                        <dl class="item">
                            <dt>
                                <a href="" class="text-area">[text]</a>
                                <a href="" class="text-name">title</a>
                                <span class="price">13000</span>
                            </dt>
                            <dd class="tag-1">
                                <span class="tag">title</span>
                                <span class="description">test</span>
                            </dd>
                            <dd class="tag-2 clearfix">
                                <div class="picture-left fl">
                                    <a href=""><img src="../images/consult_hot_purchase.jpg" alt=""></a>
                                </div>
                                <div class="content-right fl">
                                    <p>description</p>
                                    <a href="">link</a>
                                </div>
                            </dd>
                        </dl>
                        <dl class="item">
                            <dt>
                                <a href="" class="text-area">[text]</a>
                                <a href="" class="text-name">title</a>
                                <span class="price">13000</span>
                            </dt>
                            <dd class="tag-1">
                                <span class="tag">title</span>
                                <span class="description">test</span>
                            </dd>
                            <dd class="tag-2 clearfix">
                                <div class="picture-left fl">
                                    <a href=""><img src="../images/consult_hot_purchase.jpg" alt=""></a>
                                </div>
                                <div class="content-right fl">
                                    <p>description</p>
                                    <a href="">link</a>
                                </div>
                            </dd>
                        </dl>
                        <dl class="item">
                            <dt>
                                <a href="" class="text-area">[text]</a>
                                <a href="" class="text-name">title</a>
                                <span class="price">13000</span>
                            </dt>
                            <dd class="tag-1">
                                <span class="tag">title</span>
                                <span class="description">test</span>
                            </dd>
                            <dd class="tag-2 clearfix">
                                <div class="picture-left fl">
                                    <a href=""><img src="../images/consult_hot_purchase.jpg" alt=""></a>
                                </div>
                                <div class="content-right fl">
                                    <p>description</p>
                                    <a href="">link</a>
                                </div>
                            </dd>
                        </dl>
                    </div>

    js: 

    $(document).ready(function () {
            $('.consult-right .hot-purchase .item').each(function (index) {
                $(this).hover(function () {
                    $(this).addClass('on');
                    let siblings = $(this).siblings('.item');
                    siblings.removeClass('on')
                })
            })
        })
  • 相关阅读:
    散列算法
    【转】认证 (authentication) 和授权 (authorization) 的区别
    Filter和interceptor比较
    【转】深入理解Spring的两大特征(IOC和AOP)
    [转]web.xml中servlet ,filter ,listener ,interceptor的作用与区别
    线程同步
    Java容器
    进程间交互的几种方式
    JSP和Servlet的区别
    IPC介绍
  • 原文地址:https://www.cnblogs.com/Nyan-Workflow-FC/p/13168176.html
Copyright © 2011-2022 走看看