元素,返回 HTMLCollection
+const divs = document.getElementsByTagName("div");
+```
+
+### 4. 通过选择器获取(灵活)
+#### 4.1 获取单个元素
+```javascript
+// 匹配第一个符合选择器的元素,无则 null
+const firstItem = document.querySelector(".item");
+const btn = document.querySelector("#btn");
+const link = document.querySelector("a[href='https://baidu.com']");
+```
+
+#### 4.2 获取所有匹配元素
+```javascript
+// 匹配所有符合选择器的元素,返回 NodeList(伪数组)
+const allItems = document.querySelectorAll(".item");
+// 遍历 NodeList
+allItems.forEach(item => {
+ console.log(item);
+});
+```
+
+### 方法对比
+| 方法 | 返回值 | 动态/静态 | 特点 |
+|------|--------|-----------|------|
+| `getElementById` | 单个元素 | - | 最快,仅匹配 ID |
+| `getElementsByClassName` | HTMLCollection | 动态(DOM 变化自动更新) | 按类名匹配,伪数组 |
+| `getElementsByTagName` | HTMLCollection | 动态 | 按标签名匹配 |
+| `querySelector` | 单个元素 | 静态 | 支持 CSS 选择器,灵活 |
+| `querySelectorAll` | NodeList | 静态 | 支持 CSS 选择器,批量匹配 |
+
+## 四、创建/插入/删除 DOM 节点
+### 1. 创建节点
+```javascript
+// 创建元素节点(如
)
+const newDiv = document.createElement("div");
+// 设置内容和样式
+newDiv.textContent = "新创建的div";
+newDiv.className = "new-item";
+
+// 创建文本节点(较少单独使用)
+const textNode = document.createTextNode("纯文本内容");
+
+// 创建属性节点(可直接用 setAttribute 替代)
+const attrNode = document.createAttribute("data-id");
+attrNode.value = "123";
+newDiv.setAttributeNode(attrNode);
+```
+
+### 2. 插入节点
+| 方法 | 说明 | 示例 |
+|------|------|------|
+| `parent.appendChild(child)` | 将子节点添加到父节点的末尾 | `document.body.appendChild(newDiv);` |
+| `parent.insertBefore(newNode, refNode)` | 将新节点插入到参考节点之前 | `const box = document.getElementById("box");`
`box.insertBefore(newDiv, box.firstChild);` |
+| `element.replaceChild(newNode, oldNode)` | 替换节点 | `box.replaceChild(newDiv, box.children[0]);` |
+
+### 3. 删除节点
+```javascript
+// 方式1:父节点删除子节点
+const box = document.getElementById("box");
+box.removeChild(box.children[0]);
+
+// 方式2:节点自身删除(ES6+)
+const item = document.querySelector(".item");
+item.remove();
+```
+
+### 4. 克隆节点
+```javascript
+// 克隆节点:true 表示深克隆(包含子节点),false 仅克隆自身
+const cloneDiv = newDiv.cloneNode(true);
+document.body.appendChild(cloneDiv);
+```
+
+## 五、操作文档内容
+### 1. 文本/HTML 内容
+```javascript
+const box = document.getElementById("box");
+
+// 设置/获取纯文本(推荐,避免 XSS)
+box.textContent = "Hello World";
+console.log(box.textContent); // 输出 "Hello World"
+
+// 设置/获取 HTML 内容(有 XSS 风险,谨慎使用)
+box.innerHTML = "
Hello World
";
+console.log(box.innerHTML); // 输出 "
Hello World
"
+```
+
+### 2. 属性操作
+```javascript
+const input = document.querySelector("input");
+
+// 设置属性
+input.setAttribute("type", "password");
+input.setAttribute("placeholder", "请输入密码");
+
+// 获取属性
+const type = input.getAttribute("type"); // "password"
+
+// 判断是否存在属性
+if (input.hasAttribute("disabled")) {
+ input.removeAttribute("disabled");
+}
+
+// 自定义属性(data-*)
+input.dataset.id = "456"; // 设置 data-id="456"
+console.log(input.dataset.id); // "456"
+```
+
+## 六、文档事件
+### 1. 文档加载事件
+```javascript
+// 方式1:DOM 加载完成(DOMContentLoaded)—— 无需等待资源加载
+document.addEventListener("DOMContentLoaded", () => {
+ console.log("DOM 已加载完成,可操作元素");
+});
+
+// 方式2:页面完全加载(包括图片、样式等资源)
+window.onload = () => {
+ console.log("页面所有资源加载完成");
+};
+```
+
+### 2. 其他常用文档事件
+```javascript
+// 点击事件(文档级别委托)
+document.addEventListener("click", (e) => {
+ // 事件委托:判断点击的目标元素
+ if (e.target.classList.contains("btn")) {
+ console.log("按钮被点击");
+ }
+});
+
+// 键盘事件
+document.addEventListener("keydown", (e) => {
+ if (e.key === "Enter") {
+ console.log("回车键被按下");
+ }
+});
+```
+
+## 七、常用工具方法
+| 方法 | 说明 | 示例 |
+|------|------|------|
+| `document.write()` | 直接向文档写入内容(慎用,会覆盖页面) | `document.write("
临时内容
");` |
+| `document.querySelector()` | 见「获取 DOM 元素」 | - |
+| `document.createElement()` | 见「创建节点」 | - |
+| `document.getElementById()` | 见「获取 DOM 元素」 | - |
+| `document.hasFocus()` | 判断文档是否获得焦点 | `console.log(document.hasFocus());` |
+| `document.createElementNS()` | 创建命名空间元素(如 SVG) | `const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");` |
+
+## 八、注意事项
+1. **DOM 操作性能**:频繁操作 DOM 会触发重排/重绘,建议批量操作(如用 DocumentFragment 暂存节点):
+ ```javascript
+ const fragment = document.createDocumentFragment();
+ for (let i = 0; i < 100; i++) {
+ const div = document.createElement("div");
+ fragment.appendChild(div);
+ }
+ document.body.appendChild(fragment); // 仅一次重排
+ ```
+
+2. **空值判断**:获取元素后需先判断是否为 null,避免报错:
+ ```javascript
+ const box = document.getElementById("box");
+ if (box) { // 非空才操作
+ box.textContent = "内容";
+ }
+ ```
+
+3. **XSS 风险**:避免使用 `innerHTML` 插入不可信内容,优先用 `textContent`。
+
+4. **动态 vs 静态集合**:`getElementsByClassName` 返回的 HTMLCollection 是动态的,遍历前建议转为数组,避免因 DOM 变化导致遍历异常。
+
+## 九、总结
+`document` 对象是 JS 操作页面的核心,核心能力可归纳为:
+- **查**:通过 ID、类名、选择器获取元素;
+- **改**:修改元素内容、属性、样式;
+- **增**:创建节点并插入文档;
+- **删**:删除/替换节点;
+- **监听**:处理文档加载、交互事件。
+
+掌握以上内容可覆盖 90% 以上的 DOM 操作场景,实际开发中需结合性能优化(如减少 DOM 操作次数、事件委托)提升页面效率。
+
+# 练习
+示例图:
+## 训练1
+```js
+
+
+ 123
+
+ //训练1
+ function btnConvert() {
+ let body = document.body;
+ body.style.backgroundColor = "red";
+ body.style.color = "white";
+ }
+```
+示例图:
+## 训练2
+```js
+ //训练2
+ document.writeln("
当前文档的文件名称:" + document.URL);
+```
+示例图:
+## 训练3
+```js
+
+
+
+
+ //训练3
+ let str = '123456789';
+ function btnAdd() {
+ let txt = document.getElementById("txt");
+ // txt.value += "a";
+ for (let i = 0; i < str.length; i++) {
+ setTimeout(() => {
+ txt.value = str.substring(0, i + 1);
+ }, i * 1000);
+ }
+
+ }
+```
+示例图:
+## 综合练习1
+```js
+
+
+
标题
+ 文字
+ 文字
+ 文字
+ 文字
+ 文字
+
+ //综合练习1
+ function chooseTheme() {
+ let box = document.querySelector("#colorTheme").value;
+ let body = document.getElementById("box-colorTheme");
+ if (box == "a") {
+ body.style.backgroundColor = "";
+ body.style.color = "";
+ } else if (box == "b") {
+ body.style.backgroundColor = "green";
+ body.style.color = "white";
+ }
+ }
+```
+
+## 综合练习2
+```js
+
打开图片对话框
+ //综合练习2
+ function openImg(e) {
+ e.preventDefault();
+ let imgDiv = document.createElement("div");
+ imgDiv.style.width = "100px";
+ imgDiv.style.height = "100px";
+ imgDiv.style.border = "1px solid #000";
+ imgDiv.style.float = "left";
+
+ let deleteBtn = document.createElement("input");
+ deleteBtn.type = "button";
+ deleteBtn.value = "X删除";
+ deleteBtn.style.cssText = "float:right; border: none; background: transparent;";
+ deleteBtn.onclick = () => document.body.removeChild(imgDiv);
+
+ let img = document.createElement("img");
+ img.src = "#";
+
+ imgDiv.appendChild(img);
+ imgDiv.appendChild(deleteBtn);
+ document.body.appendChild(imgDiv);
+
+ }
+```
+
+## 综合练习3
+```js
+
+ //综合练习3
+ function addImg() {
+ let imgDiv = document.createElement("div");
+ imgDiv.style.cssText = "width:100px; height:100px; border:1px solid #000 "
+ imgDiv.style.float = "left";
+ document.body.appendChild(imgDiv);
+
+ let img = document.createElement("img");
+ img.src = "#";
+ imgDiv.appendChild(img);
+
+ for (let i = 1; i < 3; i++) {
+ setTimeout(() => {
+ document.body.appendChild(imgDiv.cloneNode(true));
+ }, i * 1000);
+ }
+
+ }
+```
diff --git "a/\351\203\255\345\260\217\344\270\234/20251204-DOM.md" "b/\351\203\255\345\260\217\344\270\234/20251204-DOM.md"
new file mode 100644
index 0000000000000000000000000000000000000000..1994d520754299b66a7a54e753acf473298c77ff
--- /dev/null
+++ "b/\351\203\255\345\260\217\344\270\234/20251204-DOM.md"
@@ -0,0 +1,403 @@
+# 笔记
+## DOM概述
+
+ DOM是document object model 的缩写,意为文档对象模型.
+
+## 节点
+
+### 节点种类
+
+ - 根节点
+ - 父节点
+ - 子节点
+ - 兄弟节点
+ - 后代
+ - 叶节点
+### 节点属性
+
+|属性|说明|属性|说明|
+|-|-|-|-|
+|nodeName|节点的名称|firstChild|返回当前节点的第一个子节点|
+|nodeValue|节点的值,通常只用于文本节点|lastChild|返回当前节点的最后一个子节点|
+|nodeType|节点的类型|previousSibling|返回当节点的前一个兄弟节点|
+|parentNode|返回当前节点的父节点|lasnextSiblingtChild|返回当节点的后一个兄弟节点|
+|childNodes|子节点列表|attribuites|元素的属性列表|
+
+### 创建节点
+```js
+obj.appendchild(newChild);
+```
+### 插入节点
+```js
+obj.insertBefore(new,ref);
+```
+### 复制节点
+```js
+obj.cloneNode(deep);
+```
+### 删除与替换节点
+```js
+obj.removeChild(oldChild);
+```
+## 获取文档中的指定元素
+### 通过元素的id属性获取元素
+```js
+document.getElementByid("id");
+```
+### 通过元素的class属性获取元素
+```js
+document.getElementByClassName("id");
+```
+## 与DHTML相对应的DOM
+### innerHTML 和 innerText属性
+```js
+ document.getElementByid("id").innerHTML = "内容";
+```
+### outerHTML 和 outerText属性
+```js
+ document.getElementByid("id").outerHTML = "内容";
+```
+
+# 练习
+示例图:
+## 训练1
+```js
+
+
+
+
+
+
+
+ function addColor() {
+ let txt = document.getElementById("box1-inputText");
+ let selectColor = document.querySelector("#selectColor");
+ let color = selectColor.value;
+ let span = document.createElement('span');
+ if (color == "a") {
+ span.style.color = "";
+ } else if (color == "b") {
+ span.style.color = "red";
+ } else if (color == "c") {
+ span.style.color = "blue";
+ }
+ let getText = txt.value;
+ let txtNode = document.createTextNode(getText);
+ span.appendChild(txtNode);
+
+ document.getElementById("box1-1").appendChild(span);
+
+ txt.value = "";
+
+ }
+```
+示例图:
+## 训练2、训练3
+```js
+
+ // 训练2
+ function addText() {
+
+ let txt = document.getElementById('box2-inputText');
+ let li = document.createElement('li');
+ let ul = document.getElementById("box2-ul");
+
+ let getText = txt.value;
+ getText = getText.trim();
+ let txtNode = document.createTextNode(getText);
+ li.appendChild(txtNode);
+
+
+ let str = ['1', '2', '3', '4', '5']
+
+
+ if (str.includes(getText)) {
+ ul.appendChild(li);
+ } else {
+ alert(getText === "" ? "请输入内容" : "请输入正确内容");
+ }
+
+
+
+ txt.value = "";
+ }
+
+ //训练3
+ function deleteText() {
+ let ul = document.getElementById('box2-ul');
+ let txt = document.getElementById('box2-inputText');
+
+
+ let getText = txt.value.trim();
+
+ let liList = ul.querySelectorAll("li");
+
+ for (let i = 0; i < liList.length; i++) {
+ let li = liList[i]
+ if (li.textContent.trim() === getText) {
+ ul.removeChild(liList[i]);
+ txt.value = "";
+ return;
+ }
+ }
+
+
+ // let targetLi = null;
+ // // 5. 遍历查找匹配文本的li
+ // for (let li of liList) {
+ // // li.textContent 获取li的纯文本内容(等价于文本节点的nodeValue)
+ // if (li.textContent.trim() === getText) {
+ // targetLi = li;
+ // break; // 找到第一个匹配的li,停止遍历
+ // }
+ // }
+ }
+
+```
+示例图:
+## 训练4
+```js
+
+ function moveFood() {
+ let vegUl = document.getElementById("vegetables");
+ let fruUl = document.getElementById("fruit");
+
+ let vegLastLi = vegUl.lastElementChild;
+ let fruLastLi = fruUl.lastElementChild;
+
+ vegUl.replaceChild(fruLastLi.cloneNode(true), vegLastLi);
+ fruUl.replaceChild(vegLastLi.cloneNode(true), fruLastLi);
+ // vegUl.replaceChild(fruLastLi, vegLastLi);
+ // fruUl.appendChild(vegLastLi);
+
+
+ }
+```
+示例图:
+## 训练5
+```js
+
+ function btnSubmit() {
+ let radio = document.querySelectorAll('input[name="box5-radio"]');
+ let radioValue = null;
+ for (let i = 0; i < radio.length; i++) {
+ //核心:判断当前单选框是否被选中
+ if (radio[i].checked) {
+ radioValue = radio[i].value;
+ break;
+ }
+ }
+ console.log(radioValue);
+
+ if (radioValue === "武当") {
+ alert("答案正确");
+
+ } else if (!radioValue) {
+ alert("请选择一个答案!");
+ } else {
+ alert("答案错误");
+ }
+ }
+```
+示例图:
+## 训练6
+```js
+
+ //训练6
+ function btnEdit() {
+ let alink = document.getElementById("alink");
+ alink.innerHTML = "修改后的超链接";
+ alink.href = "123";
+ document.getElementById("box6").appendChild(aLink);
+
+ }
+```
+示例图:
+## 训练7
+```js
+
+ //训练7
+ function btnAdd() {
+ let img = document.getElementById("box7-1");
+ img.innerHTML += "

";
+ img.style.cssText = "height:200px; width:200px; border: 1px solid black;";
+ // let addImg = img.appendChild(img);
+
+ }
+```
+示例图:
+## 综合练习1
+```js
+
+ // 综合练习1
+ function aEdit() {
+ let bText = document.getElementById("box1-1");
+ let newItext = document.createElement("i");
+ newItext.textContent = bText.children[0].textContent;
+ bText.replaceChild(newItext, bText.children[0]);
+ }
+```
+
+## 综合练习2
+```js
+
+
+
+
+
+ function aEdit() {
+ let bText = document.getElementById("box1-1");
+ let newItext = document.createElement("i");
+ newItext.textContent = bText.children[0].textContent;
+ bText.replaceChild(newItext, bText.children[0]);
+ }
+ // 综合练习2
+ let year = document.getElementById("year");
+ let month = document.getElementById("month");
+ let day = document.getElementById("day");
+
+ //年
+ function initYear() {
+ let now = new Date();
+ let currentYear = now.getFullYear();
+ for (let i = 1990; i <= currentYear; i++) {
+ let option = document.createElement("option");
+ option.value = i;
+ option.textContent = i + "年";
+ year.appendChild(option);
+ }
+ year.value = currentYear;
+ }
+
+ //月
+ function initMonth() {
+ let now = new Date();
+ let currenMonth = now.getMonth();
+ for (let i = 1; i <= 12; i++) {
+ let option = document.createElement("option");
+ option.value = i;
+ option.textContent = i + "月";
+ month.appendChild(option);
+ }
+ month.value = currenMonth;
+ }
+
+ //日
+ function initDay() {
+ let selectYear = parseInt(year.value);
+ let selectMonth = parseInt(month.value);
+ let selectDay = new Date(selectYear, selectMonth, 0).getDate();
+ day.innerHTML = "";
+ for (let i = 1; i <= selectDay; i++) {
+ let option = document.createElement("option");
+ option.value = i;
+ option.textContent = i + "日";
+ day.appendChild(option);
+ }
+ let currentDay = new Date().getDate();
+ day.value = currentDay > selectMonth ? selectMonth : currentDay;
+ }
+ // 联动
+ year.addEventListener("change", function () {
+ initDay();
+ })
+ month.addEventListener("change", initDay);
+ //引用
+ initYear();
+ initMonth();
+ initDay();
+```
+
+## 综合练习3
+```js
+
+
请选择表情
+
+
+
+ // 综合练习3
+ function selectImg() {
+ let selImg = document.querySelector("#selImg")?.value;
+ let img = document.getElementById("box3-1");
+ console.log(selImg);
+ console.log(img);
+
+
+ if (selImg == 2 && img) {
+ img.innerHTML = "

";
+ } else if (selImg == 3 && img) {
+ img.innerHTML = "

";
+ } else if (img) {
+ img.innerHTML = "";
+ }
+
+ }
+ document.addEventListener("DOMContentLoaded", function () {
+ selectImg(); // 保留原执行逻辑
+ // 新增:绑定下拉框change事件
+ const selImgEle = document.querySelector("#selImg");
+ if (selImgEle) {
+ selImgEle.addEventListener("change", selectImg);
+ }
+ })
+```
diff --git "a/\351\203\255\345\260\217\344\270\234/20251205-Window\345\257\271\350\261\241.md" "b/\351\203\255\345\260\217\344\270\234/20251205-Window\345\257\271\350\261\241.md"
new file mode 100644
index 0000000000000000000000000000000000000000..47461ed0aa712d0d53945afd4da7ba16138cff9a
--- /dev/null
+++ "b/\351\203\255\345\260\217\344\270\234/20251205-Window\345\257\271\350\261\241.md"
@@ -0,0 +1,441 @@
+# 笔记
+## 一、Window 对象概述
+### 1. 核心定位
+`window` 是 JavaScript 中 **BOM(浏览器对象模型)的顶层对象**,代表浏览器的一个窗口或标签页,是 JS 与浏览器交互的核心桥梁。
+
+- 它是全局作用域的载体,所有全局变量、全局函数都会自动成为 `window` 的属性和方法。
+- 调用 `window` 的属性或方法时,可省略 `window` 前缀(如 `alert()` 等价于 `window.alert()`)。
+- 每个窗口/标签页对应一个独立的 `window` 对象,不同窗口的 `window` 互不干扰(受跨域限制)。
+
+### 2. 核心作用
+- 控制浏览器窗口(打开、关闭、调整大小)。
+- 操作浏览器地址栏、历史记录。
+- 实现弹窗交互(提示、确认、输入)。
+- 管理定时器、本地存储。
+- 监听窗口级事件(加载、缩放、滚动)。
+- 承载全局变量和函数。
+
+## 二、Window 核心子对象(高频)
+### 1. document(DOM 桥梁)
+`window.document` 是连接 BOM 与 DOM 的桥梁,代表当前页面的文档对象,用于操作页面 DOM 结构。
+```javascript
+// 示例:获取页面元素(省略 window 前缀)
+document.querySelector("#box");
+document.body.style.backgroundColor = "red";
+```
+
+### 2. location(地址栏操作)
+`window.location` 用于操作浏览器地址栏,控制页面导航和 URL 相关操作,核心属性和方法如下:
+| 属性/方法 | 说明 | 示例 |
+|-----------|------|------|
+| `href` | 获取/设置完整 URL(常用页面跳转) | `location.href = "https://example.com";` |
+| `host` | 返回域名 + 端口号 | `console.log(location.host); // 如 "www.baidu.com:80"` |
+| `hostname` | 返回域名(不含端口) | `console.log(location.hostname); // "www.baidu.com"` |
+| `pathname` | 返回 URL 中的路径部分 | `console.log(location.pathname); // 如 "/index.html"` |
+| `search` | 返回 URL 中的查询参数(?后面部分) | `console.log(location.search); // 如 "?id=123"` |
+| `hash` | 返回 URL 中的哈希值(#后面部分) | `console.log(location.hash); // 如 "#top"` |
+| `reload()` | 刷新当前页面 | `location.reload(); // 强制刷新加 true:location.reload(true)` |
+| `replace(url)` | 替换当前页面(不保留历史记录,无法后退) | `location.replace("https://example.com");` |
+
+### 3. history(历史记录管理)
+`window.history` 用于操作浏览器的历史记录,实现页面前进、后退功能。
+| 方法 | 说明 | 示例 |
+|------|------|------|
+| `back()` | 后退到上一页(等价于浏览器“后退”按钮) | `history.back();` |
+| `forward()` | 前进到下一页(等价于浏览器“前进”按钮) | `history.forward();` |
+| `go(n)` | 跳转到历史记录中指定位置(n 为正数前进,负数后退) | `history.go(-2); // 后退2页` |
+| `length` | 属性,返回历史记录的条数 | `console.log(history.length); // 查看当前窗口的历史记录总数` |
+
+### 4. navigator(浏览器/设备信息)
+`window.navigator` 用于获取浏览器和当前设备的相关信息,常用属性如下:
+```javascript
+// 获取浏览器名称(部分浏览器会隐藏真实名称)
+console.log(navigator.appName);
+
+// 获取浏览器版本信息
+console.log(navigator.appVersion);
+
+// 获取用户代理字符串(常用于判断浏览器类型和设备)
+console.log(navigator.userAgent);
+
+// 判断是否为移动设备(通过用户代理匹配)
+const isMobile = /Mobile|Android|iOS/.test(navigator.userAgent);
+console.log(isMobile ? "移动设备" : "桌面设备");
+
+// 获取当前浏览器支持的语言
+console.log(navigator.language); // 如 "zh-CN"
+```
+
+### 5. screen(屏幕信息)
+`window.screen` 用于获取显示器屏幕的相关信息,常用属性如下:
+```javascript
+// 屏幕总宽高(包括任务栏等系统组件)
+console.log(screen.width, screen.height);
+
+// 屏幕可用宽高(不包括任务栏,实际可显示区域)
+console.log(screen.availWidth, screen.availHeight);
+
+// 屏幕颜色深度
+console.log(screen.colorDepth); // 通常为 24(表示真彩色)
+```
+
+## 三、Window 核心方法
+### 1. 窗口控制方法
+用于控制浏览器窗口的打开、关闭、移动和大小调整,**仅对通过 `open()` 打开的自定义窗口生效**(外部域名窗口受跨域限制)。
+| 方法 | 说明 | 示例 |
+|------|------|------|
+| `open(url, target, features)` | 打开新窗口/标签页,返回新窗口的 `window` 对象 | `const newWin = open("https://example.com", "_blank", "width=500,height=500,top=100,left=100");` |
+| `close()` | 关闭指定窗口(需通过 `open()` 返回的窗口对象调用) | `newWin.close();` |
+| `moveTo(x, y)` | 将窗口移动到屏幕指定坐标(x/y 为屏幕左上角起点) | `newWin.moveTo(200, 200);` |
+| `resizeTo(w, h)` | 将窗口调整为指定宽高 | `newWin.resizeTo(600, 400);` |
+
+### 2. 弹窗交互方法
+用于与用户进行简单交互,弹出提示、确认或输入框(样式受浏览器限制,自定义程度低)。
+| 方法 | 说明 | 示例 |
+|------|------|------|
+| `alert(msg)` | 弹出提示框(只有“确定”按钮) | `alert("操作成功!");` |
+| `confirm(msg)` | 弹出确认框(有“确定”和“取消”按钮),返回布尔值 | `const isConfirm = confirm("确定要删除吗?");` |
+| `prompt(msg, defaultVal)` | 弹出输入框,返回用户输入的内容(取消则返回 null) | `const username = prompt("请输入用户名:", "默认用户名");` |
+
+### 3. 定时器方法
+用于延迟执行代码或定期执行代码,是前端常用的异步操作方式。
+#### 3.1 一次性定时器(setTimeout)
+延迟指定时间后执行一次代码,返回定时器 ID(用于清除定时器)。
+```javascript
+// 语法:setTimeout(回调函数, 延迟时间(毫秒), 传递给回调的参数)
+const timer1 = setTimeout((name) => {
+ console.log(`Hello ${name}`);
+}, 1000, "张三");
+
+// 清除一次性定时器(未执行前有效)
+clearTimeout(timer1);
+```
+
+#### 3.2 周期性定时器(setInterval)
+每隔指定时间重复执行代码,返回定时器 ID。
+```javascript
+// 语法:setInterval(回调函数, 间隔时间(毫秒))
+const timer2 = setInterval(() => {
+ console.log("每隔2秒执行一次");
+}, 2000);
+
+// 清除周期性定时器(必须手动清除,否则会一直执行)
+clearInterval(timer2);
+```
+
+### 4. 本地存储方法
+用于在浏览器中存储数据(无过期时间,仅在当前域名下有效),核心有两种方式:
+#### 4.1 localStorage(永久存储)
+数据存储在浏览器中,除非手动删除,否则永久保留,容量约 5MB。
+```javascript
+// 存储数据(键值对,值必须是字符串)
+localStorage.setItem("username", "zhangsan");
+localStorage.setItem("age", 20); // 自动转为字符串 "20"
+
+// 获取数据
+const username = localStorage.getItem("username");
+console.log(username); // "zhangsan"
+
+// 删除指定数据
+localStorage.removeItem("age");
+
+// 清空所有数据
+localStorage.clear();
+```
+
+#### 4.2 sessionStorage(会话存储)
+数据仅在当前会话(窗口/标签页)有效,关闭窗口后数据自动删除,容量约 5MB。
+```javascript
+// 用法与 localStorage 一致,仅存储时效不同
+sessionStorage.setItem("token", "abc123");
+const token = sessionStorage.getItem("token");
+sessionStorage.removeItem("token");
+```
+
+## 四、Window 常用事件
+### 1. 页面加载事件
+| 事件 | 说明 | 示例 |
+|------|------|------|
+| `load` | 页面**完全加载完成**(包括图片、样式、脚本等所有资源)后触发 | `window.onload = () => { console.log("页面全部加载完成"); }` |
+| `DOMContentLoaded` | DOM 结构加载完成(无需等待图片、样式等资源)后触发,比 `load` 更早 | `document.addEventListener("DOMContentLoaded", () => { console.log("DOM 加载完成"); });` |
+
+### 2. 窗口尺寸事件
+```javascript
+// 窗口大小发生变化时触发(如缩放浏览器)
+window.addEventListener("resize", () => {
+ // 获取窗口可视区域宽高(常用)
+ const winWidth = window.innerWidth;
+ const winHeight = window.innerHeight;
+ console.log(`窗口宽:${winWidth}px,高:${winHeight}px`);
+});
+```
+
+### 3. 页面滚动事件
+```javascript
+// 页面滚动时触发(如滚动鼠标滚轮)
+window.addEventListener("scroll", () => {
+ // 获取页面滚动的距离(垂直方向)
+ const scrollTop = window.scrollY;
+ // 获取页面滚动的距离(水平方向)
+ const scrollLeft = window.scrollX;
+ console.log(`垂直滚动:${scrollTop}px`);
+});
+```
+
+### 4. 其他常用事件
+- `beforeunload`:页面关闭或刷新前触发,可提示用户确认离开。
+- `hashchange`:URL 中的哈希值(#后面部分)变化时触发,常用于单页应用路由。
+
+## 五、注意事项
+1. **全局变量与 window 的关系**:用 `var` 声明的全局变量会成为 `window` 的属性,用 `let`/`const` 声明的全局变量不会(但仍在全局作用域中)。
+ ```javascript
+ var a = 10;
+ console.log(window.a); // 10(var 声明会挂载到 window)
+
+ let b = 20;
+ console.log(window.b); // undefined(let 声明不会挂载)
+ ```
+
+2. **跨域限制**:不同域名的窗口,无法通过 `window` 对象相互操作(如获取对方的 `location`、调用对方的方法),浏览器会拦截跨域操作以保障安全。
+
+3. **定时器清除**:周期性定时器(`setInterval`)必须手动用 `clearInterval` 清除,否则会一直执行,导致内存泄漏。
+
+4. **弹窗限制**:现代浏览器对 `open()` 弹出的窗口有拦截策略,仅在用户交互(如点击事件)中调用 `open()`,才能正常弹出窗口。
+
+5. **存储数据格式**:`localStorage` 和 `sessionStorage` 仅能存储字符串,存储对象/数组时需先转为 JSON 字符串,读取时再解析。
+ ```javascript
+ // 存储对象
+ const user = { name: "张三", age: 20 };
+ localStorage.setItem("user", JSON.stringify(user));
+
+ // 读取对象
+ const userData = JSON.parse(localStorage.getItem("user"));
+ ```
+
+## 六、总结
+`window` 对象是 JS 操作浏览器的核心,核心能力可归纳为:
+- **窗口控制**:打开、关闭、调整窗口大小。
+- **导航操作**:通过 `location` 跳转页面、`history` 管理历史记录。
+- **信息获取**:通过 `navigator`/`screen` 获取浏览器、设备信息。
+- **交互能力**:弹窗交互、定时器、本地存储。
+- **事件监听**:监听页面加载、窗口缩放、滚动等事件。
+
+# 练习
+
+## 训练1
+```html
+
+
+```
+```js
+// 训练1
+document.querySelector('#audio').addEventListener('play', () => {
+ alert('只有会员才能播放歌曲,请登录!');
+ audio.pause();
+})
+```
+## 训练2
+```html
+
+
+
退出登录
+```
+```js
+// 训练2
+function aBtn() {
+ alert("您确定退出登录吗")
+}
+```
+## 训练3
+```html
+
+

+
+
+
+
×
+
+
603字母节目
+
导演:wrh
+
主演:wrh,lct
+
剧情简介:神秘刺激的字母情节
+
+
+```
+```js
+// 训练3
+function imgBtn() {
+ let modal = document.getElementById('modalMask');
+ modal.style.display = 'flex';
+}
+function closeModal() {
+ let modal = document.getElementById('modalMask');
+ modal.style.display = 'none'; // 隐藏弹窗
+}
+```
+## 训练4
+```html
+
+```
+```js
+// 训练4
+let window4 = window.open("new.html", "new", "height=200,width=200");
+setTimeout(() => {
+ window4.close();
+
+}, 5000);
+```
+## 训练5
+```html
+
+
+
+
+```
+```js
+// 训练5
+function openBtn() {
+ let window4 = window.open("new.html", "new", "height=200,width=200");
+ setTimeout(() => {
+ let currentX = window4.screenX;
+ let currentY = window4.screenY;
+ let targetY = currentY + 200; // 最终向下移200px
+ let step = 5; // 每帧移动5px(越小越平滑)
+
+ // 逐帧移动
+ let moveTimer = setInterval(() => {
+ currentY += step;
+ // 到达目标位置后停止
+ if (currentY >= targetY) {
+ currentY = targetY;
+ clearInterval(moveTimer);
+ }
+ window4.moveTo(currentX, currentY);
+ }, 16); // 约60帧/秒,保证流畅
+ }, 2000);
+}
+```
+## 训练6
+```html
+
+
+
+
+
+
+```
+```js
+// 训练6
+let txt = document.getElementById("box6-text");
+let time = 1;
+let timer1 = null, timer2 = null;
+
+
+function startTimingBtn() {
+ timer1 = setInterval(() => {
+ txt.value = time;
+ }, 1000);
+
+ timer2 = setInterval(() => {
+ time++;
+ return time;
+ }, 1000);
+}
+function endTimingBtn() {
+ clearInterval(timer1);
+ clearInterval(timer2);
+ timer1 = null;
+ timer2 = null;
+}
+```
+## 综合练习1
+```html
+
+
+```
+```js
+// 综合练习1
+function btnCalculate() {
+ let num1, num2;
+ num1 = Math.floor(Math.random() * 10);
+ num2 = Math.floor(Math.random() * 10);
+ let correctAnswer = num1 + num2;
+ let answer;
+ let dialog1 = prompt(`${num1}+${num2}=`, answer);
+ if (dialog1 === null) {
+ alert("你取消了答题~");
+ return;
+ }
+ answer = Number(dialog1);
+ if (answer == correctAnswer) {
+ let dialog2 = confirm(`回答正确是否继续答题`);
+ if (dialog2) {
+ btnCalculate();
+ } else {
+ let dialog3 = alert(`您拒绝了继续答题`);
+ return;
+ }
+ } else {
+ alert("回答错误");
+ }
+}
+```
+## 综合练习2
+```html
+
+
+```
+```js
+// 综合练习2
+function btnChoose() {
+ let correctAnswer = "D";
+ let answer;
+ let dialog1 = prompt("2024年奥运会在那座城市举办?\n\n\nA.罗马\nB.北京\nC.伦敦\nD.巴黎", answer);
+ answer = String(dialog1);
+ console.log(answer);
+
+ if (answer == correctAnswer) {
+ alert("答案正确");
+ } else {
+ alert("答案错误");
+ }
+}
+```
+## 综合练习3
+```html
+
+
+
+```
+```js
+// 综合练习3
+function btnAddPicture() {
+ let img = ["./OIP-C.webp", "./OIP-C2.webp", "OIP-C3.jpg", "OIP-C4.webp", "OIP-C5.jpg"];
+ let imgContainer = document.getElementById("div1");
+ imgContainer.innerHTML = "";
+ for (let i = 0; i < img.length; i++) {
+
+ setTimeout(() => {
+ console.log(i);
+ let addimg = document.createElement("img");
+ addimg.style.width = "100px"
+ // addimg.style.height = "100px"
+ addimg.src = img[i];
+ document.getElementById("div1").appendChild(addimg);
+ if (i == img.length - 1) {
+
+ setTimeout(() => {
+ btnAddPicture();
+ }, 1000);
+ }
+ }, i * 1000);
+ }
+
+
+}
+```
\ No newline at end of file
diff --git "a/\351\203\255\345\260\217\344\270\234/20251208-\346\270\270\350\247\210\345\231\250\345\257\271\350\261\241\346\250\241\345\236\213.md" "b/\351\203\255\345\260\217\344\270\234/20251208-\346\270\270\350\247\210\345\231\250\345\257\271\350\261\241\346\250\241\345\236\213.md"
new file mode 100644
index 0000000000000000000000000000000000000000..d2a169bfc7a467a01773e0bbbb33dab85d920123
--- /dev/null
+++ "b/\351\203\255\345\260\217\344\270\234/20251208-\346\270\270\350\247\210\345\231\250\345\257\271\350\261\241\346\250\241\345\236\213.md"
@@ -0,0 +1,292 @@
+# 笔记
+
+## 一、BOM 概述
+
+### 1. 定义
+
+BOM(Browser Object Model,浏览器对象模型)是用于操作浏览器窗口及浏览器组件的 API 集合,**无官方统一标准**(不同浏览器略有差异),核心作用是与浏览器本身交互(而非页面内容)。
+
+### 2. BOM 与 DOM 的区别
+
+| 维度 | BOM(浏览器对象模型) | DOM(文档对象模型) |
+| -------- | ------------------------------------ | ------------------------------------ |
+| 操作对象 | 浏览器窗口、地址栏、历史记录等 | 页面 HTML/XML 文档内容(标签、文本) |
+| 核心对象 | window(顶级)、location、history 等 | document(根节点)、element、node 等 |
+| 标准 | 无统一标准,浏览器自定义实现 | W3C 标准化,跨浏览器兼容性好 |
+| 示例操作 | 页面跳转、弹窗、获取浏览器信息 | 新增标签、修改样式、绑定事件 |
+
+## 二、BOM 核心对象
+
+### 1. window 对象(核心)
+
+`window` 是 BOM 的顶级对象,代表浏览器窗口,**所有全局变量 / 函数都是 window 的属性 / 方法**(可省略 `window.` 直接调用)。
+
+#### 核心属性
+
+| 属性名 | 说明 | 示例 |
+| ------------------------ | ----------------------------------------- | --------------------------------------- |
+| `document` | 指向 DOM 的根对象,操作页面内容 | `window.document.getElementById('box')` |
+| `location` | 管理当前页面 URL 信息 | `window.location.href` |
+| `navigator` | 获取浏览器 / 系统信息 | `window.navigator.userAgent` |
+| `history` | 管理浏览器历史记录 | `window.history.back()` |
+| `screen` | 获取屏幕显示信息 | `window.screen.width` |
+| `innerWidth/innerHeight` | 浏览器视口(可视区域)宽 / 高(不含边框) | `console.log(window.innerWidth)` |
+
+#### 核心方法
+
+| 方法名 | 说明 | 示例 |
+| --------------------------- | ----------------------------------------------- | ------------------------------------------------------------ |
+| `alert(msg)` | 弹出提示框(无返回值) | `alert('操作成功')` |
+| `confirm(msg)` | 弹出确认框(返回布尔值:确认→true,取消→false) | `let res = confirm('确定删除?');` |
+| `prompt(msg, default)` | 弹出输入框(返回输入内容 /null) | `let name = prompt('请输入姓名', '张三');` |
+| `open(url, name, params)` | 打开新窗口(params:宽高 / 位置等) | `window.open('https://www.baidu.com', '_blank', 'width=500,height=300')` |
+| `close()` | 关闭当前窗口(仅对 `open` 打开的窗口有效) | `window.close()` |
+| `setTimeout(fn, delay)` | 一次性定时器(delay:毫秒) | `let timer = setTimeout(() => {console.log('1秒后执行')}, 1000);` |
+| `clearTimeout(timer)` | 清除一次性定时器 | `clearTimeout(timer)` |
+| `setInterval(fn, interval)` | 循环定时器 | `let timer = setInterval(() => {console.log('每秒执行')}, 1000);` |
+| `clearInterval(timer)` | 清除循环定时器 | `clearInterval(timer)` |
+
+### 2. location 对象
+
+`window.location`(可简写为 `location`)用于管理当前页面的 URL 信息,支持跳转、刷新等操作。
+
+#### 核心属性(URL 拆解示例:`https://www.baidu.com:8080/search?name=张三#top`)
+
+| 属性名 | 说明 | 示例值 |
+| ---------- | ------------------ | ------------------------------------------------- |
+| `href` | 完整 URL | `https://www.baidu.com:8080/search?name=张三#top` |
+| `protocol` | 协议(含 `://`) | `https:` |
+| `host` | 主机 + 端口 | `www.baidu.com:8080` |
+| `hostname` | 主机(不含端口) | `www.baidu.com` |
+| `port` | 端口号 | `8080` |
+| `pathname` | 路径 | `/search` |
+| `search` | 查询参数(含 `?`) | `?name=张三` |
+| `hash` | 哈希锚点(含 `#`) | `#top` |
+
+#### 核心方法
+
+| 方法名 | 说明 | 示例 |
+| --------------- | ---------------------------------------- | ------------------------------------------- |
+| `assign(url)` | 跳转到指定 URL(保留历史记录,可后退) | `location.assign('https://www.baidu.com')` |
+| `replace(url)` | 替换当前 URL(无历史记录,不可后退) | `location.replace('https://www.baidu.com')` |
+| `reload(force)` | 刷新页面(force=true:强制从服务器刷新) | `location.reload(true)` |
+
+#### 实战示例:解析 URL 查询参数
+
+javascript
+
+
+
+运行
+
+
+
+
+
+
+
+
+
+```javascript
+// 解析 ?name=张三&age=18 为对象 {name: '张三', age: '18'}
+function getUrlParams() {
+ const params = {};
+ const search = location.search.slice(1); // 去掉?,得到name=张三&age=18
+ if (!search) return params;
+ search.split('&').forEach(item => {
+ const [key, value] = item.split('=');
+ params[key] = decodeURIComponent(value); // 解码中文
+ });
+ return params;
+}
+console.log(getUrlParams()); // {name: '张三', age: '18'}
+```
+
+### 3. navigator 对象
+
+`window.navigator`(可简写为 `navigator`)用于获取浏览器、操作系统、设备等信息。
+
+#### 核心属性
+
+| 属性名 | 说明 | 示例 |
+| ----------- | ----------------------------------- | --------------------- |
+| `userAgent` | 用户代理字符串(浏览器 / 系统标识) | `navigator.userAgent` |
+| `language` | 浏览器默认语言(如 zh-CN) | `navigator.language` |
+| `platform` | 操作系统平台(如 Win32、MacIntel) | `navigator.platform` |
+
+#### 实战示例:判断浏览器类型
+
+javascript
+
+
+
+运行
+
+
+
+
+
+
+
+
+
+```javascript
+// 判断是否为 Chrome 浏览器
+function isChrome() {
+ return /Chrome/.test(navigator.userAgent) && !/Edge/.test(navigator.userAgent);
+}
+console.log(isChrome()); // true/false
+```
+
+### 4. history 对象
+
+`window.history`(可简写为 `history`)用于管理浏览器的会话历史记录(仅能操作,无法获取具体 URL)。
+
+#### 核心方法
+
+| 方法名 | 说明 | 示例 |
+| ----------- | --------------------------------------------------------- | ---------------------------- |
+| `back()` | 后退一页(等同于浏览器后退按钮) | `history.back()` |
+| `forward()` | 前进一页(等同于浏览器前进按钮) | `history.forward()` |
+| `go(n)` | 跳转指定步数(n>0:前进 n 页;n<0:后退 n 页;n=0:刷新) | `history.go(-1)` // 后退一页 |
+
+### 5. screen 对象
+
+`window.screen`(可简写为 `screen`)用于获取设备屏幕的显示信息。
+
+#### 核心属性
+
+| 属性名 | 说明 | 示例 |
+| ------------------------ | ------------------------------------- | ------------------------------- |
+| `width/height` | 屏幕总分辨率(宽 / 高) | `screen.width` // 如 1920 |
+| `availWidth/availHeight` | 屏幕可用分辨率(不含任务栏 / 状态栏) | `screen.availHeight` // 如 1080 |
+
+## 三、BOM 常用实战场景
+
+### 1. 弹窗交互(确认 + 输入)
+
+javascript
+
+
+
+运行
+
+
+
+
+
+
+
+
+
+```javascript
+// 确认删除并输入原因
+function deleteConfirm() {
+ const isConfirm = confirm('确定要删除这条记录吗?');
+ if (isConfirm) {
+ const reason = prompt('请输入删除原因(选填)', '');
+ if (reason !== null) { // 取消输入返回null
+ alert(`删除成功!原因:${reason || '无'}`);
+ }
+ }
+}
+deleteConfirm();
+```
+
+### 2. 页面倒计时跳转
+
+javascript
+
+
+
+运行
+
+
+
+
+
+
+
+
+
+```javascript
+// 5秒后跳转到首页
+let count = 5;
+const timer = setInterval(() => {
+ count--;
+ if (count <= 0) {
+ clearInterval(timer);
+ location.href = '/index.html';
+ }
+ console.log(`${count}秒后跳转...`);
+}, 1000);
+```
+
+### 3. 判断移动端 / PC 端
+
+javascript
+
+
+
+运行
+
+
+
+
+
+
+
+
+
+```javascript
+function isMobile() {
+ return /Mobile|Android|iOS|iPhone|iPad|iPod/.test(navigator.userAgent);
+}
+if (isMobile()) {
+ alert('当前为移动端访问');
+} else {
+ alert('当前为PC端访问');
+}
+```
+
+## 四、注意事项
+
+1. **兼容性问题**:BOM 无统一标准,部分 API(如 `userAgent` 格式、`open` 方法参数)在不同浏览器(如 IE/Chrome/Firefox)中表现有差异,需做兼容处理。
+
+2. 全局作用域
+
+ :
+
+ - `var` 声明的全局变量 / 函数会成为 `window` 的属性;
+ - `let/const` 声明的全局变量不会挂载到 `window` 上。
+
+ javascript
+
+
+
+ 运行
+
+
+
+
+
+
+
+
+
+ ```javascript
+ var a = 1;
+ let b = 2;
+ console.log(window.a); // 1
+ console.log(window.b); // undefined
+ ```
+
+
+
+3. **弹窗拦截**:浏览器会拦截非用户触发的 `window.open`(如直接在脚本中调用),需绑定到点击 / 触摸等用户事件中。
+
+4. **定时器精度**:`setTimeout/setInterval` 受主线程阻塞影响,并非绝对精确(延迟时间≥设置值)。
+
+5. **窗口操作限制**:`close` 方法仅能关闭由 `open` 打开的窗口,无法关闭用户手动打开的浏览器窗口。
+
+6. **安全限制**:部分 BOM API(如 `history`、`location`)受同源策略限制,跨域无法操作。
\ No newline at end of file
diff --git "a/\351\203\255\345\260\217\344\270\234/20251210-Style\345\257\271\350\261\241.md" "b/\351\203\255\345\260\217\344\270\234/20251210-Style\345\257\271\350\261\241.md"
new file mode 100644
index 0000000000000000000000000000000000000000..8f4ec689fd099a94314022d3d395146d14f22f68
--- /dev/null
+++ "b/\351\203\255\345\260\217\344\270\234/20251210-Style\345\257\271\350\261\241.md"
@@ -0,0 +1,336 @@
+
+# 笔记
+## 一、Style 对象概述
+### 1. 定义
+Style 对象是 JavaScript 操作 DOM 元素**行内样式(inline style)** 的核心接口,对应 HTML 元素的 `style` 属性。通过 Style 对象可动态读取/修改元素的 CSS 样式,所有样式属性均为可读可写。
+
+### 2. 核心特点
+| 特性 | 说明 |
+|--------------|----------------------------------------------------------------------|
+| 操作范围 | 仅作用于元素的行内样式(`style="xxx"`),不包含外部样式表/内嵌样式的样式 |
+| 属性命名 | 驼峰命名法(对应 CSS 的短横线命名),如 `css` 的 `background-color` → `js` 的 `backgroundColor` |
+| 取值格式 | 所有属性值均为字符串,且需包含单位(如 `10px`、`red`、`50%`)|
+| 优先级 | 行内样式优先级最高(高于 CSS 选择器),会覆盖同名的外部/内嵌样式 |
+
+### 3. Style 对象 vs getComputedStyle
+| 对比维度 | Style 对象 | window.getComputedStyle() |
+|----------------|-------------------------------------|------------------------------------|
+| 操作类型 | 读写(可修改样式)| 只读(仅获取最终生效的样式)|
+| 样式范围 | 仅行内样式 | 所有样式(行内/内嵌/外部)|
+| 返回值格式 | 带单位的字符串(如 `20px`)| 带单位的字符串(如 `20px`)|
+| 适用场景 | 动态修改元素样式 | 获取元素最终渲染的样式值 |
+
+## 二、Style 对象核心用法
+### 1. 获取 Style 对象
+通过 DOM 元素的 `style` 属性直接获取,语法:
+```javascript
+// 获取元素
+const elem = document.getElementById("box");
+// 获取 Style 对象(可直接操作)
+const elemStyle = elem.style;
+```
+
+### 2. 样式属性命名规则
+CSS 样式属性名含短横线的,需转为**驼峰命名**;无短横线的直接使用:
+
+| CSS 属性名 | Style 对象属性名 | 示例 |
+|---------------------|------------------------|-------------------------------|
+| `width` | `width` | `elem.style.width = "100px"` |
+| `background-color` | `backgroundColor` | `elem.style.backgroundColor = "red"` |
+| `font-size` | `fontSize` | `elem.style.fontSize = "16px"` |
+| `border-radius` | `borderRadius` | `elem.style.borderRadius = "8px"` |
+| `text-align` | `textAlign` | `elem.style.textAlign = "center"` |
+| `margin-top` | `marginTop` | `elem.style.marginTop = "5px"` |
+
+### 3. 读取/修改样式
+#### (1)修改样式(核心)
+直接给 Style 对象的属性赋值(值为带单位的字符串):
+```javascript
+const box = document.getElementById("box");
+// 基础样式
+box.style.width = "200px";
+box.style.height = "100px";
+box.style.backgroundColor = "#f5f5f5";
+// 复合样式(需拆分,Style 对象不支持复合写法)
+// ❌ 错误:不支持 "border: 1px solid #000" 复合写法
+box.style.border = "1px solid #000"; // 部分浏览器兼容,但不推荐
+// ✅ 推荐拆分写法
+box.style.borderWidth = "1px";
+box.style.borderStyle = "solid";
+box.style.borderColor = "#000";
+// 特殊样式(如 transform)
+box.style.transform = "rotate(10deg)";
+box.style.transition = "all 0.3s ease";
+```
+
+#### (2)读取样式(仅行内样式)
+```javascript
+// 仅能读取通过 style 设置的行内样式,无行内样式则返回空字符串
+console.log(box.style.width); // "200px"(已设置)
+console.log(box.style.color); // ""(未设置行内样式)
+```
+
+#### (3)获取最终生效的样式(含非行内)
+需结合 `window.getComputedStyle()`:
+```javascript
+// 获取最终渲染的样式(只读)
+const computedStyle = window.getComputedStyle(box);
+console.log(computedStyle.width); // "200px"
+console.log(computedStyle.color); // "#333"(来自外部样式表)
+// 转为数字(去除单位)
+const widthNum = parseInt(computedStyle.width); // 200
+const heightNum = parseFloat(computedStyle.height); // 100
+```
+
+### 4. 清除样式
+#### (1)清空单个样式
+赋值为空字符串:
+```javascript
+box.style.backgroundColor = ""; // 清除背景色行内样式,恢复默认/外部样式
+```
+
+#### (2)清空所有行内样式
+使用 `removeAttribute` 移除 `style` 属性:
+```javascript
+box.removeAttribute("style"); // 清空所有行内样式
+```
+
+## 三、Style 对象常用属性分类
+### 1. 布局相关属性
+| Style 属性名 | 说明 | 示例值 |
+|--------------------|--------------------|-----------------------|
+| `width/height` | 宽/高 | `"100px"`、`"50%"` |
+| `minWidth/minHeight` | 最小宽/高 | `"50px"` |
+| `maxWidth/maxHeight` | 最大宽/高 | `"300px"` |
+| `margin/marginTop/marginRight/marginBottom/marginLeft` | 外边距 | `"10px"`、`"5px 10px"` |
+| `padding/paddingTop/paddingRight/paddingBottom/paddingLeft` | 内边距 | `"8px"` |
+| `display` | 显示方式 | `"block"`、`"none"`、`"flex"`、`"inline-block"` |
+| `position` | 定位方式 | `"static"`、`"relative"`、`"absolute"`、`"fixed"`、`"sticky"` |
+| `top/left/right/bottom` | 定位偏移量 | `"20px"`、`"0"` |
+| `zIndex` | 层级 | `"999"`、`"1"` |
+| `float` | 浮动 | `"left"`、`"right"`、`"none"` |
+| `clear` | 清除浮动 | `"both"`、`"left"` |
+
+### 2. 视觉样式属性
+| Style 属性名 | 说明 | 示例值 |
+|--------------------|--------------------|-----------------------|
+| `backgroundColor` | 背景色 | `"red"`、`"#fff"`、`"rgba(0,0,0,0.5)"` |
+| `backgroundImage` | 背景图 | `"url('bg.jpg')"` |
+| `color` | 文字颜色 | `"#333"`、`"white"` |
+| `border` | 边框(复合)| `"1px solid #000"` |
+| `borderRadius` | 圆角 | `"8px"`、`"50%"`(圆形) |
+| `boxShadow` | 盒子阴影 | `"0 2px 8px rgba(0,0,0,0.2)"` |
+| `opacity` | 透明度(0-1)| `"0.8"` |
+| `cursor` | 鼠标光标 | `"pointer"`、`"move"`、`"default"` |
+
+### 3. 文字/字体属性
+| Style 属性名 | 说明 | 示例值 |
+|--------------------|--------------------|-----------------------|
+| `fontSize` | 字体大小 | `"14px"`、`"1.2rem"` |
+| `fontWeight` | 字体粗细 | `"normal"`、`"bold"`、`"600"` |
+| `fontFamily` | 字体 | `"微软雅黑, sans-serif"` |
+| `textAlign` | 文字对齐 | `"left"`、`"center"`、`"right"` |
+| `textDecoration` | 文字装饰 | `"none"`、`"underline"`、`"line-through"` |
+| `lineHeight` | 行高 | `"20px"`、`"1.5"` |
+
+### 4. 变换/过渡属性
+| Style 属性名 | 说明 | 示例值 |
+|--------------------|--------------------|-----------------------|
+| `transform` | 变换 | `"rotate(10deg)"`、`"scale(1.2)"`、`"translateX(20px)"` |
+| `transition` | 过渡 | `"all 0.3s ease"`、`"backgroundColor 0.5s"` |
+| `animation` | 动画 | `"fade 1s infinite"` |
+
+## 四、实战示例
+### 1. 动态修改元素样式(鼠标悬浮效果)
+```javascript
+const btn = document.getElementById("btn");
+// 鼠标悬浮
+btn.addEventListener("mouseover", () => {
+ btn.style.backgroundColor = "#007bff";
+ btn.style.color = "white";
+ btn.style.cursor = "pointer";
+ btn.style.transform = "scale(1.05)";
+});
+// 鼠标离开
+btn.addEventListener("mouseout", () => {
+ btn.style.backgroundColor = "";
+ btn.style.color = "";
+ btn.style.transform = "";
+});
+```
+
+### 2. 批量设置列表项样式
+```javascript
+const liItems = document.querySelectorAll("li");
+liItems.forEach((li, index) => {
+ // 基础样式
+ li.style.paddingLeft = "10px";
+ li.style.margin = "5px 0";
+ li.style.borderRadius = "0 10px 10px 0";
+ // 交替背景色
+ li.style.backgroundColor = index % 2 === 0 ? "#f0f0f0" : "#fff";
+});
+```
+
+### 3. 获取元素最终样式并计算偏移
+```javascript
+const box = document.getElementById("box");
+// 获取最终样式
+const computed = window.getComputedStyle(box);
+// 计算元素实际宽度(含内边距,不含边框)
+const innerWidth = parseInt(computed.width);
+const paddingLeft = parseInt(computed.paddingLeft);
+const paddingRight = parseInt(computed.paddingRight);
+const actualWidth = innerWidth + paddingLeft + paddingRight;
+console.log(`元素实际内容宽度:${actualWidth}px`);
+```
+
+### 4. 动态调整文本框高度
+```javascript
+const textarea = document.getElementById("textarea");
+const increaseBtn = document.getElementById("increaseBtn");
+// 增高按钮
+increaseBtn.addEventListener("click", () => {
+ const currentHeight = parseInt(window.getComputedStyle(textarea).height);
+ textarea.style.height = (currentHeight + 50) + "px";
+});
+```
+
+## 五、注意事项
+1. **单位必须加**:所有数值型样式(如 width、margin)必须带单位(px/%/rem 等),否则无效:
+ ```javascript
+ box.style.width = 100; // ❌ 无效(无单位)
+ box.style.width = "100px"; // ✅ 有效
+ ```
+2. **复合样式慎用**:Style 对象对 `border`、`background` 等复合样式的支持不一致,推荐拆分为单个属性(如 `borderWidth`、`borderColor`)。
+3. **优先级问题**:行内样式优先级最高,若需覆盖 Style 对象设置的样式,需在 CSS 中使用 `!important`,或直接清空行内样式。
+4. **CSS 变量操作**:可通过 `style.setProperty`/`style.getPropertyValue` 操作 CSS 变量:
+ ```javascript
+ // 设置 CSS 变量
+ box.style.setProperty("--main-color", "blue");
+ // 读取 CSS 变量
+ const mainColor = box.style.getPropertyValue("--main-color"); // "blue"
+ ```
+5. **兼容性**:
+ - 部分属性(如 `transform`)在旧版浏览器需加前缀(`webkitTransform`、`mozTransform`);
+ - `getComputedStyle` 不支持 IE8 及以下,需用 `elem.currentStyle` 兼容。
+6. **空值处理**:读取未设置的行内样式会返回空字符串,需先判断再使用:
+ ```javascript
+ const color = box.style.color || "#333"; // 兜底默认值
+ ```const color = box.style.color || "#333"; // 兜底默认值
+
+
+# 练习
+
+## 训练1
+```html
+
+
+
+ 鸡你太美
+
+```
+```js
+function btnEnlarge() {
+ let size = 2;
+ let txt = document.getElementById("txt");
+ let currentFontSize = window.getComputedStyle(txt).fontSize;
+ let fontSizeNum = parseFloat(currentFontSize);
+ let newFontSize = (fontSizeNum + size) + "px";
+ txt.style.fontSize = newFontSize;
+
+ let clior = getComputedStyle(txt).clior;
+
+
+ let random1 = Math.floor(Math.random() * 256);
+ let random2 = Math.floor(Math.random() * 256);
+ let random3 = Math.floor(Math.random() * 256);
+ txt.style.clior = `rgb(${random1},${random2},${random3})`;
+ conslie.log(clior);
+}
+```
+
+## 训练2
+```html
+
+
+```
+```js
+// 训练2
+function cssImg() {
+ let img = document.createElement('img');
+ img.src = "../20251205/OIP-C5.jpg";
+ img.style.width = "100px";
+ document.getElementById("box2").appendChild(img);
+
+ img.addEventListener('mouseover', function () {
+ this.style.border = "5px double blue";
+ this.style.boxSizing = "border-box";
+ })
+
+ img.addEventListener('mouseout', function () {
+ this.style.border = 'none';
+ })
+}
+```
+
+## 综合练习1
+```html
+
+
+ - HTML/CSS讨论区
+ - JavaScript讨论区
+ - C语言讨论区
+ - Java讨论区
+ - Android讨论区
+ - Python讨论区
+
+
+```
+```js
+// 训练1
+function btnEnlarge() {
+ let size = 2;
+ let txt = document.getElementById("txt");
+ let currentFontSize = window.getComputedStyle(txt).fontSize;
+ let fontSizeNum = parseFloat(currentFontSize);
+ let newFontSize = (fontSizeNum + size) + "px";
+ txt.style.fontSize = newFontSize;
+
+ let clior = getComputedStyle(txt).clior;
+
+
+ let random1 = Math.floor(Math.random() * 256);
+ let random2 = Math.floor(Math.random() * 256);
+ let random3 = Math.floor(Math.random() * 256);
+ txt.style.clior = `rgb(${random1},${random2},${random3})`;
+ conslie.log(clior);
+}
+```
+## 综合练习2
+```html
+
+```
+```js
+// 训练2
+function cssImg() {
+ let img = document.createElement('img');
+ img.src = "../20251205/OIP-C5.jpg";
+ img.style.width = "100px";
+ document.getElementById("box2").appendChild(img);
+
+ img.addEventListener('mouseover', function () {
+ this.style.border = "5px double blue";
+ this.style.boxSizing = "border-box";
+ })
+
+ img.addEventListener('mouseout', function () {
+ this.style.border = 'none';
+ })
+}
+```
diff --git "a/\351\203\255\345\260\217\344\270\234/20251211-Form\345\257\271\350\261\241.md" "b/\351\203\255\345\260\217\344\270\234/20251211-Form\345\257\271\350\261\241.md"
new file mode 100644
index 0000000000000000000000000000000000000000..0624a059c87e1bf5f95b1768fa40a58935c84ec6
--- /dev/null
+++ "b/\351\203\255\345\260\217\344\270\234/20251211-Form\345\257\271\350\261\241.md"
@@ -0,0 +1,588 @@
+# 笔记
+## 一、Form 对象概述
+### 1. 定义
+Form 对象是 JavaScript 操作 HTML 表单(`