jquery初步学习 选择器

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="jquery-3.3.1.js"></script>
    <script>
        $(document).ready(function () {
            $("button").click(function () {
                alert("hello")
            });
            $("#show").click(sum);
        });
        function sum() {
            alert(2+3)
        }
    </script>
</head>
<body>
    <button>点击1</button>
    <input type="button" value="点击2" id="show"/>
</body>
</html>

结果
点击【点击1】按钮弹出”hello”
点击【点击2】按钮弹出”5”

猜你喜欢

转载自blog.csdn.net/weixin_38052444/article/details/81777734