How To Add Target=_blank To All Pdf Links Inside Div Using Jquery?
For example: I want to add target=_blank in any PDF link comes inside this css class 'class='newWindow' Before adding script
Solution 1:
Code
$(".newWindow a[href$='pdf']").attr('target','_blank');
:]
Preview:
View code
Note:
in jsbin example, I also add class .bl
, so you can easily see result :]
No Conflict mode:
jQuery.noConflict();
jQuery(".newWindow a[href$='pdf']").attr('target','_blank');
or
jQuery.noConflict();
jQuery(document).ready(function($){
$(".newWindow a[href$='pdf']").attr('target','_blank');
});
or another way, take a look here: http://docs.jquery.com/Using_jQuery_with_Other_Libraries
Solution 2:
This should work
$(".newWindow a[href$='.pdf']").attr("target", "_blank");
Post a Comment for "How To Add Target=_blank To All Pdf Links Inside Div Using Jquery?"