本地js文件下载地址:链接:https://pan.baidu.com/s/1Xa2bjmprjBDdRNbEQCj81Q
提取码:mz24
JQ的基本使用
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JQ的导入</title>
<!-- 导入JQ框架 -->
<script src="js/jquery.min.js"></script>
<!-- 1. 寻找目标文件
2. 下载文件
3. 解析文件 -->
</head>
<body>
<div id="tip">
hello, world!
</div>
<!-- 添加一个ID为marry -->
<input type="checkbox"
name="marry",
id="marry">婚否
<script>
//输出jq对象
console.log($("#tip"));
//输出dom对象
console.log(document.getElementById("tip"));
// dom ==> jq对象
console.log($(document.getElementById("tip")));
// jq对象 ==> dom对象
console.log($("#tip")[0])
// 1.使用JQ选择器 获取元素
// 2.改变元素显示的内容
// document.getElementById("tip").innerText = "今天天气很好";
$("#tip").html("<b>今天天气很好</b>");
console.log($("#tip").attr("id"));
//获取jq对象 checked/undefined
console.log($("#marry").attr("checked"));
//获取jq对象 true/false
console.log($("#marry").prop("checked"));
</script>
</body>
</html>