6. Adding and removing cl@sses


This code works in the editor, but Codecademy doesn't seem to this so ('oops, try again'). I have refreshed several times...

$(document).ready(function() {
$('#text').click(function() {



It should be highlighted(small case l)


Ah yes. That was just something I tried. But unfortunately that wasn't the problem :frowning:


Oh actually, it is working now. Thanks! :slight_smile:


Just wondering about best practices:

I solved this with the following inside the document.ready function:
$('#text').on('click', function(){

Is there any reason to do this via the event handler instead of the easier to type
I would guess that it affords more flexibility long term, since one can then add a second parameter to specify the element to listen for inside a div.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.