查找下一个元素,虽然该元素有其他父元素(但是共同的祖先)?

cim*_*mak 1 jquery

如何获得第二天.选择

$('day.selected').next('day')
Run Code Online (Sandbox Code Playgroud)

仅适用于同一周内的几天.

<calendar>
    <month>
        <week>
            <day/>
            <day class='selected'/>
        </week>

        <week>
            <day/>   //How to get this?
            <day/>
        </week>
    </month>

    <month>
    .
    .
</calendar>
Run Code Online (Sandbox Code Playgroud)

Aru*_*hny 6

作为查找第二天元素的一般解决方案(与父元素无关)

var idx = $('day.selected').index('day'),
    $next = $('day').eq(idx + 1);
Run Code Online (Sandbox Code Playgroud)

演示:小提琴,也看到这个