[jQuery] find ".pdf" extension
Hi,
I'm looking for a great solution to find 'a' tag which have href which
finish by '.pdf' (or any other extention) cause my pdf link haven't specific
class.
To be more accurate, i must find <div> which containts 'a' tag with href
which finish by '.pdf' to wrap the pdf link in a <div class="extra">
Actually, i use this code:
function createExtraLink(){
$('.rt-mcms-article :has(a)').append('<div class="extra">download
:
</div>');
var lnk = $('.rt-mcms-article').children('p').find('a');
$(lnk).each(function(i){
var fileLnk = $(this).attr('href');
var extension = fileLnk.substring(fileLnk.lastIndexOf("."));
if( extension == ".pdf"){
$(this).parents('.rt-mcms-article').find('.extra').append(' '+fileLnk+'
'+$(this).text()+' ')
}
});
}
work great to create link in my <div class="extra"> but create this div in
any case where my <div class=".rt-mcms-article"> contains 'a' tag (so if i
have hypertext link, it will be create too)...
not a good way...
someone can helmp me?
thanks
--
View this message in context: http://www.nabble.com/find-%22.pdf%22-extension-tp18717034s27240p18717034.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.