Js if there is a class called A, and there are many classes whose class is An on the page, how do you find out the An other than the current A?

if there is a class called An and there are many classes with class An on the page, how do you find out the An other than the current A?

<ul>
    <li class="A">
        <ul>
            <li class="A">
                
            </li>
            <li class="A">
                <ul>
                    <li class="A">
                        
                    </li>
                </ul>
            </li>
        </ul>
    </li>
    <li class="A" >
        
    </li>
</ul>

how do I find all An except the current element?

Mar.19,2021

//jq
var index = $('.A').index($(this))
console.log($('.A:not(:eq('+index+'))'))

this can use JS event delegate, currenttarget refers to the current element, and then you can bind the event to write if (event.target.tagName = = currentarget.tagName) {write the statement you want to execute in parentheses}
this way is called event proxy, also known as event delegate.


jq : $('div'). Not ($(' div'). Eq (1))
Menu