jquery元素获取
children() 获取子元素
siblings() 获取所有的兄弟元素
parent() 获取父元素
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
</head>
<body>
<!-- 兄弟,父子节点 -->
<ul>
<li>html</li>
<li>css</li>
<li>javascript</li>
</ul>
<!--
children()
siblings()
parent()
获取所有的兄弟元素 -->
<script>
$("li").click(function(){
$(this).css({color:"red"}).siblings().css({color:"green"})
})
console.log($("ul").parent())
</script>
</body>
</html>
事件
$(document).ready({}) 文档完全加载完后,不包含外部的资源文件的(图片,视频,音频)
window.onload = function(){} 等页面和外部的资源文件都加载完毕,才会执行函数中的内容
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<img src="" alt="">
<p>hello world</p>
<script>
//文档完全加载完后,不包含外部的资源文件的(图片,视频,音频)
// $(document).ready({
// })
// 简写
$(function(){
})
/* 等页面和外部的资源文件都加载完毕,才会执行函数中的内容 */
window.onload = function(){
}
</script>
</body>
</html>
then
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<body>
<script>
/* axios 是一个promise */
var url ="http://localhost:8000/more"
axios.get(url).then(res=>{
console.log(res)
})
</script>
</body>
</html>