Pages

26 Aug 2013

Basic jQuery.each() Function Example using JQuery


$('a').each(function(index, value){
      console.log($(this).attr('href'));
});
//outputs: every links href element on your web page

$('a').each(function(index, value){
    var ihref = $(this).attr('href');
    if (ihref.indexOf("http") >= 0)
    {
        console.log(ihref+'<br/>');
    }
});
//outputs: every external href on your web page

No comments:

Post a Comment