mardi 10 octobre 2017

li jquery on click: if to switch

I'm making a simple filter system where each li value has a certain description. Currently it's working with an IF statement, but I'd like to convert it to a switch. Is this possible?

Thanks in advance.

My code:

$("ul.simplefilter").on('click', 'li', function (e) {

if($(this).text() == "Iedereen"){
    $("#uitleg p").remove();
    $("#uitleg").append("<p>Iedereen</p>");        
}
else if($(this).text() == "Coach studentenparticipatie"){ 
    $("#uitleg p").remove();    
    $("#uitleg").append("<p>Coach studentenparticipatie</p>");
}
else if($(this).text() == "Communicatie"){ 
    $("#uitleg p").remove();    
    $("#uitleg").append("<p>Communicatie</p>");
}
else if($(this).text() == "Coördinator"){ 
    $("#uitleg p").remove();    
    $("#uitleg").append("<p>Coördinator</p>");
}
})

Aucun commentaire:

Enregistrer un commentaire