문제

How can i request all anchors on a single HTML document?

$('.notfront article a[href!=http]').attr('href')

return only the first match,

$('.notfront article a').attr('href').match(/^#\w+/g)

also return only the first element.

도움이 되었습니까?

해결책

function getAnchorElements(){
    var elems = [];
    $('.notfront article a').each(function(){
        if($(this).attr('href').match(/^#\w+/g))
            elems.push(this);
    });
    return elems;
}

다른 팁

This should select them without the foreach loop.

$(".notfront article a[href^='#']" ).
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top