批改状态:合格
老师批语:jquery更多知识查手册,https://www.jq22.com/
一个优秀的JavaScript代码库(或JavaScript框架)
<!-- 1.本地源码 --><script src="jquery-3.5.1.js"></script><!-- 2.远程源码库cdn --><script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
1.$()2.jquery()$() === jquery()
//获取h2标签,并把标签元素前景色变成red$('h2').css('color','red');
//$()内包含的是js原生对象$(document.body).css("background-color", "blue");//....spread扩展, ....rest归并将jquery对象还原成原生的js对象集合[...$(document.querySelectorAll("li"))].forEach(li => (li.style.color = "violet"));//et(n),[n]: 将jQuery集合中的某一个对象还原成原生的js对象$(document.querySelectorAll("li"))[0].style.backgroundColor = "yellow";
$("<li>这里是用jquery插入的内容</li>").appendTo(document.querySelector("body"));

<head><script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script><script>$(function () {$("<li>这里是用jquery插入的内容</li>").appendTo(document.querySelector("body"));console.log(document.querySelector("body"));});</script></head>
<h2>用户登录</h2><form action="login.php" method="GET"><label for="username">用户名:</label><input type="text" name="username" id="username" value="admin@admin.com" /><label for="password">密码:</label><input type="password" name="password" id="password" placeholder="密码不能少于六位" /><button>登录</button></form>$("form").attr("action");//输出 login.php
//设置action的值为:register.php$("form").attr("action", "register.php");
//通过method属性来判断用哪个文件处理//toUpperCase() 将字符串转换成大写form.attr("action", () => {let method = form.attr("method").toUpperCase();return method === "GET" ? "query.php?id=2" : "register.php";});
//获取form元素的width值$("form").css("width")
$("form").css("width","500px");

let form = $("form");form.css({background: "red","border-bottom": "10px solid #000",});

//设置form背景色随机const form = $("form");form.css("background-color", () => {const colors = ["red", "blue", "yellow", "pink"];let i = Math.floor(Math.random() * colors.length);return colors[i];});
"$("#username").val();
"$("#username").val("manage@admin.com");
"$("#username").val(()=>"test@admin.com");
$("h2").html();

$("h2").text();

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号