Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript jQuery Basics Working with jQuery Collections Changing Element Properties

What is wrong with my code?

I tried doing the challenge on my own but it didn't work, upon seeing how treasure did it, my code seems same but still not working. I am using chrome.

const pdf = $('a[href$=".pdf"]');
pdf.attr("download",true);

2 Answers

Richard Eldridge
Richard Eldridge
8,229 Points

According to caniuse.com, the download attribute is supported; however, it is "ignored" on cross-origin links on the newest versions of Chrome. I believe that is the source of the problem. I am having the same issue.

Edit: Alan M. posted a solution on a different post that worked for me.

Richard Eldridge
Richard Eldridge
8,229 Points

https://caniuse.com/#search=download

Click on the "Known Issues" tab, and you will see what I was talking about.

Steven Parker
Steven Parker
231,269 Points

That explains the problems with Firefox or Chrome. Could you provide a link to the post with the solution by Alan M.?

Steven Parker
Steven Parker
231,269 Points

There's nothing obvious in this little snippet, perhaps the problem is elsewhere. You can share your entire environment if you make a snapshot of your workspace and post the link to it here.

Also, when you say "not working", exactly what are you doing and what do you expect to happen?