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 trialAndrea Zajicova
7,124 PointsLooping through a jQuery collection: the code from the video works okay in the devTools but not in the Worskapces. Why?
I launched the Worskspace for this video and copied Treasure´s code correctly (even with the backticks):
$('a').each(function(index, link){
const url = $(link).attr('href');
$(link).parent().append((${url})
);
});
When I refresh the preview it doesn´t work though. So I tried to copy the code correctly in the Console of devTools and refreshed the preview and all works well!
I was wondering: Why? It happened to me in several previous videos. That the exactly copied code would only work from the devTools console, but not from the Workspaces.
It usually gives me this error in the devTools console:
Uncaught SyntaxError: missing ) after argument list app.js.4
So I diligently check the line 4 in app.js every time, but there is nothing missing nor nothing wrong. It is a brain teaser indeed:)
Thank you for your explanation:) I love the courses!
1 Answer
Andrea Zajicova
7,124 PointsIt is working:) Hurray!
There was an error on line 4 in app.js. Originally it was this:
const $pdfCheckbox = $('<label><input type='checkbox'> Allow PDF downloads</label>');
This is the new corrected version:
const $pdfCheckbox = $('<label><input type="checkbox"/> Allow PDF downloads</label>');
I changed the single quotes into double quotes and added a closing slash and it started to work! I just copied this line from the index.html before and didn't think more about it until today.
Happy coding and bug finding:)!