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,224 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,224 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
176,634 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
176,634 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?