7. Toggling Cla*sses [CANT SOLVE!]


#1


Hi guys, I can't get past this test. Looks like I've done the right code to solve this level.

The error says; "Oops, try again. Did you replace your .addCla*ss() with a .toggleCla*ss()?" in the matter fact, I've replaced it. Looks like I'm missing something here, any help from you js ninjas will be appreciated.

The exercise is about toggling cla*ss on jQuery object.


My code is working just fine in the console. See the code below:


$(document).ready(function() {
    $('div#text').click(function() {
    $('div#text').toggleCla*ss('highlighted');
    })
});

thanks! BTW, the * symbol in the toggleCla*ss is intentionally added (I don;t have it in the original code) to make it possible for me to post this topic. The a*ss word censor is detecting them.


#2

 $('div#text').click(function() {
    $('div#text').toggleCla*ss('highlighted');
    })

id is unique.right?so you don't need to tell here find the #text id inside div .you can simply do

$('#text').click(function(){
$('#text').toggleClass("highlighted");
    })

or

$('#text').click(function(){
$(this).toggleClass("highlighted");
   })

#3

Already solved this by using this!

But thanks anyway man, you're right -- ID is unique, I'll take note on that!


#4

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