How to optimize the judgment syntax? Look at the content ~

clipboard.png

if($(".ing>img").hasClass("show")){
                    
}else{
    $(".ing>img").addClass("show");
}
Sep.16,2021

directly $(".ing > img"). AddClass ("show"); , jq will determine whether the element className has show


jq. If you really want to optimize it, use the ternary operator < >: < >


with toggleClass, jquery1.8.3 and
seem to have been in which version.

Menu