This is probably VERY simple and silly, but I am trying to use jQuery to open all pdf's in new windows. I used the code below and get this error:
uncaught exception: Syntax error, unrecognized expression: [href$=.pdf]
I am being a nitwit, I am sure, any help would be appreciated.
Note: I subbed in jQuery for $ because I am using Wordpress.
<script type="text/javascript">
jQuery(function() {
jQuery("a[href$=.pdf]").click(function() {
window.open(this.href);
});
});
</script>
Try this:
jQuery(function($) {
$('a[href$=".pdf"]').attr('target', '_blank');
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With