开发者

How do I rewrite this jQuery more efficiently?

开发者 https://www.devze.com 2023-01-13 02:51 出处:网络
How do I rewrite this code to change a class name with jQuery more efficiently? $(function() { $(\'#container\').click(function(event) {

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';
    });
});


$(this).toggleClass('flipped');
0

精彩评论

暂无评论...
验证码 换一张
取 消