私はしようとしましたが、私は十字ボタンをクリックすると、リストを削除するようです。なぜ誰かがここで働いていないのですか? 「this」オブジェクトを使用する以外に、どの十字ボタンがクリックされたかを知るための他の方法がありますか?ここでこのオブジェクトはJavaScriptで動作していません
$(function(){
\t $("#btn").on("click",function(){
\t var text = $("#input").val();
\t if(text==""){
\t \t alert("please enter a task!");
\t }
\t else{
\t var task = $("<li></li>").text(text);
\t $(task).append("<button class= 'rem'>X</button>");
\t $("#ordered").append(task);
\t }
});
\t $(".rem").on("click",function(){
\t \t $(this).hide(1000);
\t });
});
<!DOCTYPE html>
<html lang = "en">
<head>
\t <title>Javascript Addition</title>
\t <meta charset = "utf-8">
\t
\t </head>
\t <body>
\t \t <h1>My To-Do List </h1>
\t \t <input id = "input" placeholder ="Add your task Here...">
\t \t <button id = "btn">clickkk</button>
\t \t <ol id = "ordered">
\t \t \t </ol>
\t \t <script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<script src="todo.js"></script>
</body>
</html>