Both parent and child elements have the ability to drag, how to prevent the events of the parent element.

both parent and child elements have drag-and-drop functions, how to write so that the respective drag-and-drop functions of parent and child elements do not affect each other.

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.bootcss.com/jquery/1.2.6/jquery.min.js"></script>
</head>

<body>
    <div class="container">
        <div class="bar"></div>
        <div class="poite"></div>
    </div>
    <script>
        $(".container").mousedown(function (event) {
          ...
            $(document.body).mousemove(function (event) {
                ....
            });
        });
        $(".bar").mousedown(function (event) {
          ...
            $(document.body).mousemove(function (event) {
                ....
            });
        });
        $(".poite").mousedown(function (event) {
          ...
            $(document.body).mousemove(function (event) {
                ....
            });
        });
    </script>
</body>

</html>

event.stopPropagation()

prevent events from bubbling

Menu