Pregunta

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.

¿Fue útil?

Solución

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

Otros consejos

This should select them without the foreach loop.

$(".notfront article a[href^='#']" ).
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top