Shp*_*ord 1 javascript refactoring if-statement
这是我当前的if/else语句:
var current_class = $(this).closest("article").attr("class")
if (current_class == 'opened')
{
$(this).closest("article").removeClass('opened');
$(this).closest("article").addClass('closed');
}
else
{
$(this).closest("article").removeClass('closed');
$(this).closest("article").addClass('opened');
}
Run Code Online (Sandbox Code Playgroud)
是否有更短的方式来写所有这些?看起来......超重.:)