Jquery: How to remove strikethrough on second click?

Viewed 6780

I'm just learning Jquery and wanted to use a button to add a "text-decoration" to a list item when clicked. The problem I have is that I can't use the same button to turn the "text-decoration" back to "none" on the second click?

Here is the Jquery code:

$(document).ready(function() {
    $(".button1").click(function() {
    $("ul li:nth-child(1)").css("text-decoration", "line-through");
    });
});

I tried copying line 2 and 3 and changing the text-decoration to "none" within the same function but no luck.

Thanks!

5 Answers
Related