Css style pollution?

<img class="a" src="a.svg"/>
<img class="b" src="b.svg"/>
<img class="c" src="c.svg"/>
<img class="d" src="d.svg"/>

< / div >
.a, .b, .c, .d {
display:none;
}
/ / m=num is the decision condition in the project
switch (num) {

    case 0:
        $(".a").show();
        $(".b").hide();
        $(".c").hide();
        $(".d").hide();
        break;
    case 1:
        $(".a").hide();
        $(".b").show();
        $(".c").hide();
        $(".d").hide();
        break;
    case 2:
        $(".a").hide();
        $(".b").hide();
        $(".c").show();
        $(".d").hide();
        break;
    case 3:
        $(".a").hide();
        $(".b").hide();
        $(".c").hide();
        $(".d").show();
        break;
};
svg,
Apr.02,2021

// css
.a,.b,.c,.d {
 display: none;
}
// num
var matchList = ['a','b','c','d'];
$('.'+matchList[num]).show().siblings().hide();

Don't write too much, two lines of code are done.


you can set their initial styles to hide,
switch.


Don't those svg have a div outside, give it a class name (and give it an id, such as-sharpsvg-container), and then use the script to change only the class name of div. Through the css set in advance to control the display of aPermine bPerry cPerry d under different conditions.

  1. set the style first

    $('-sharpsvg-container').attr('class','c'+ num);  //num-sharpsvg-containersvgdiv
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3b692-2c273.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3b692-2c273.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?