<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>haohao</title>
<script src="../js/jQuery-3.3.js"></script>
<script>
$(function () {
alert("hello haohao");
//接收一个字符串
//接收一个字符串选择器
var $box1 = $(".box1");
var $box2 = $(".box2");
console.log($.box1);
console.log($.box2);
//接收一个字符串代码选择器
var $p = $("<p>我是段落<p>");
console.log($p);
$box1.append($p);
//接收一个dem元素
//会被包装成一个jQuery对象返回给我们
var span = document.getElementsByClassName("span")[0];
console.log(span);
var $span = $(span);
console.log($span);
})
//JQuery的固定写法
// $(document).ready(function(){
// alert("hello haohao");
// });
</script>
</head>
<body>
<div>
</div>
<div class="box1"></div>
<div id="box2"></div>
<span>我是span</span>
</body>
</html>
jQuery核心函数!