<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="./js/JQuery.3.6.0.js"></script>
<style>
.run {
color: black;
}
.done {
color: red;
text-decoration: line-through;
}
</style>
</head>
<body>
<input type="text"><button class="add-btn">add</button>
<ul>
<li class="run">html</li>
<li class="run">css</li>
<li class="run">javascript</li>
</ul>
<a href="#">all</a>
<a href="#">run</a>
<a href="#">done</a>
<script>
$('body').on('click','.add-btn',function(){
var $input = $(this).prev();
$('ul').append(`<li>${$input.val()}</li>`);
});
$('body').on('click','ul li',function(){
var className = $(this).prop('class');
if(className == "run"){
$(this).prop('class','done');
}else{
$(this).prop('class','run');
}
});
$('body').on('click','a',function(e){
e.preventDefault();
var text = $(this).text();
switch (text) {
case "all":liShow(text);break;
case "run":liShow(text);break;
case "done":liShow(text);break;
}
});
function liShow(text){
if(text=="all"){
$('ul li').show();
}else if(text=="run"){
$('ul .run').show();
$('ul .done').hide();
}else{
$('ul .donw').show();
$('ul .run').hide();
}
$('a').each(function(){
if($(this).text()==text){
$(this).removeAttr('href');
}else{
$(this).prop('href','#');
}
})
}
</script>
</body>
</html>