Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Roald Jurrian Kamman
Front End Web Development Techdegree Graduate 15,538 Points.attr, .css, and .addClass not working.
Hey everyone. for some reason these JQuery methods aren't working for me: .attr, .css, and .addClass.
I am still left with a completely unedited page, there is no download present on the pdf and it simply links to the pdf. _blank is not added and no backgroundColor change or class has been added.
const $odd = $('a:odd');
const $secureLinks = $('a[href^="https://"]');
const $pdfs = $('a[href$=".pdf"]');
$secureLinks.attr('target', '_blank');
$pdfs.attr('download', 'true');
$odd.css('backgroundColor', 'lightgrey');
$secureLinks.addClass('secure');
$pdfs.addClass('pdf');
<!DOCTYPE html>
<html>
<head>
<title>jQuery Weekly</title>
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" title="no title" charset="utf-8">
</head>
<body>
<div class="box">
<h1>jQuery Weekly</h1>
<div id="links">
<ul>
<li><a href='https://learn.jquery.com/'>Learn jQuery</a></li>
<li><a href='http://treehouse-project-downloads.s3.amazonaws.com/jquery-basics/jquery_cheatsheet.pdf'>jQuery Cheatsheet</a></li>
<li><a href='https://api.jquery.com/'>jQuery Documentation</a></li>
<li><a href='https://developer.mozilla.org/en-US/docs/Glossary/jQuery'>jQuery Glossary</a></li>
</ul>
<label><input type='checkbox'> Allow PDF downloads</label>
</div>
</div>
<script src="js/jquery-3.2.1.min.js"></script>
<script src="js/app.js"></script>
</body>
</html>
2 Answers

Zimri Leijen
11,732 PointsWhen I copy and paste your code and run it in the workspace, it works fine

Roald Jurrian Kamman
Front End Web Development Techdegree Graduate 15,538 Pointsthat for some reason fixed all of it? Don't know why the code before the if function was broken. The if statement came after so the rest should have worked fine without it. But for some reason, everything runs now..

Zimri Leijen
11,732 Pointsnot quite sure why that happens either, you'd expect the code to break at the point where the error occurs, not before it.
Roald Jurrian Kamman
Front End Web Development Techdegree Graduate 15,538 PointsRoald Jurrian Kamman
Front End Web Development Techdegree Graduate 15,538 Pointsthat's odd None of this is working for me. The past JQuery lessons worked fine but in this series of exercises nothing works.
I got up to the rest of it and still, nothing is working.
What could be causing none of this to work? I run google chrome and have an above-average computer.
Zimri Leijen
11,732 PointsZimri Leijen
11,732 Pointsoh i'm sorry, i must have forgot to save it before i refreshed. I'll look at it again after dinner.
Zimri Leijen
11,732 PointsZimri Leijen
11,732 Pointsif $(':checked').length === 0){
should be
if ($(':checked').length === 0){