Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何更有效地重写jQuery?_Jquery - Fatal编程技术网

如何更有效地重写jQuery?

如何更有效地重写jQuery?,jquery,Jquery,如何重写此代码以更有效地使用jQuery更改类名 $(function() { $('#container').click(function(event) { var element = event.currentTarget; /* Toggle the setting of the classname attribute */ element.className = (element.className == 'card') ? 'card fli

如何重写此代码以更有效地使用jQuery更改类名

$(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');