2
我正在制作一个简单的过滤系统,其中每个li值都有一定的描述。 目前它正在使用IF语句,但我想将其转换为开关。这可能吗?li jquery点击:如果要切换
在此先感谢。
我的代码:
$("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>");
}
})
'switch($(this).text)'and case cases'case“Iedereen”:'等 – abhishekkannojia
假设的东西。尝试:'$('#uitleg')。html('
'+ $(this).text()+'
');' – Tushar