It looks like you've already worked this out, but another method to do this would be to use the document.links object. It would go something like this:
$(document.links).filter(function() { return this.indexOf('http://') == 0; }).addClass('external') On 5/10/07, stef <[EMAIL PROTECTED]> wrote:
im trying to add a class to link elements that point to an external page, using indexOf("http://") on the href attribute to see if they are internal or external links. im using the line below, but it gives an error probably cause of invalid syntax. $("a").attr("href").indexOf("http://") if i use var linksHref = $("a").attr("href") it only gets the href value of the first link, not all of them. im looping through all links to check if indexOf("http://") is == 0, if so -> add the class, if not, don't perhaps not the best technique to mark external link, but it's just a learning excercise for me. is there a way to grab ALL href attibutes on the page?