tags:

views:

50

answers:

1

How do I rewrite this code to change a class name with jQuery more efficiently?

$(function() {
    $('#container').click(function(event) {
      var element = event.currentTarget;
      /* Toggle the setting of the classname attribute */
      element.className = (element.className == 'card') ? 'card flipped' : 'card';
    });
});
+8  A: 
$(this).toggleClass('flipped');
Sjoerd
Ahhh the elegance!
jathanism