jquery链式编程

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
<meta charset="utf-8" />
    <script src="jquery-3.3.1.js"></script>
    <script>
        $(function () {
            $('#btn').click(function () {
                $('p').click(function () {
                    $(this).css('color', 'red');
                }).mouseover(function () {
                    $(this).css('cursor', 'pointer');
                }).mouseout(function () {
                    $(this).css('color', '');
                });

            });
        });
    </script>
</head>
<body>
    <input type="button" name="name" value="改变" id="btn" />
    <p>床前明月光</p>
    <p class="cls">疑是地上霜</p>
    <p>举头望明月</p>
    <p>低头思故乡</p>
</body>
</html>
原文地址:https://www.cnblogs.com/dxmfans/p/9434841.html