7/14 Highlighting not turning off


#1

Here is my code:

$(document).ready(function(){
$("#text").toggleClass("highlighted");
});

The button with id 'text' should turn highlighting on and off when clicked but with my code the highlighting is there all the time. What am I doing wrong?


#2

Ah, you don't have an actual click function. You need to create a click function with text (using the click method), and then inside of that function toggle highlighted. Like this:

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