JsjQuery 学科作业部分代码展示-选项卡版本
此页面用于存放jQ学科作业()
-为避免影响阅读,可以点击代码块内右上角的小箭头折叠单个代码块-
-幽默目录不用管😅😅😅😋ヾ(≧▽≦*)o-你别管诶嘿w-
展示网页可能因内嵌于静态构建而出现显示异常w
代码部分:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| <!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>
<div class="box">DOM</div> <script src="./js/jquery-3.7.1.min.js"></script> <script> var box = document.querySelector('.box'); console.log('box ==> ', box); var $box = $('.box'); console.log('$box ==> ', $box); var box1 = $box.get(0); console.log('box1 ==> ', box1); var $box2 = $(box); console.log('$box2 ==> ', $box2); </script> </body>
</html>
|
代码部分:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| <!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>
<h2 class="title"> jQuery </h2>
<div class="box"> <h1>CSS</h1> <ul> <li>A</li> <li>B</li> </ul> </div>
<input id="username" type="text" placeholder="输入用户名"> <button id="btn">节点内容</button> <script src="./js/jquery-3.7.1.min.js"></script> <script> $('#btn').click(function () { console.log('点击了'); var text = $('.title').text(); console.log('text ==> ', text); $('.title').text('<a>jQuery DOM 库</a>'); var html = $('.box').html(); console.log('html ==> ', html); $('.box').html('<a>jQuery DOM 库</a>'); var val = $('#username').val(); console.log('val ==> ', val); $('#username').val('Mark'); }) </script> </body>
</html>
|
代码部分:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| <!DOCTYPE html> <html lang="en">
<head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> .box { width: 300px; height: 300px; background-color: #ddd; }
.active { background-color: #e4393c; }
.br { border-radius: 20px; } </style> </head>
<body>
<div class="box br"></div> <button id="btn">样式操作</button>
<script src="./js/jquery-3.7.1.min.js"></script> <script> $('#btn').click(function () { $('.box').toggleClass('active'); $('.box').css({ width: 600, height: '500px', backgroundColor: '#bcfa1a' }) }) </script> </body>
</html>
|
代码部分:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
| <!DOCTYPE html> <html lang="en">
<head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> ul { padding: 0; list-style: none; }
li { padding: 15px 0; }
.box { width: 400px; height: 400px; background-color: #ddd; display: none; } </style> </head>
<body> <ul> <li> <span>赵云</span> <button class="edit">编辑</button> </li> <li> <span>张飞</span> <button class="edit">编辑</button> </li> <li> <span>关羽</span> <button class="edit">编辑</button> </li> <li> <span>刘备</span> <button class="edit">编辑</button> </li> </ul>
<div class="box"> <div> <input id="username" type="text" placeholder="输入用户名" /> </div> <div> <button id="save">保存</button> <button id="cancel">取消</button> </div> </div>
<script src="./js/jquery-3.7.1.min.js"></script> <script>
var $prev = null;
$('.edit').click(function () { console.log('this ==> ', this);
$prev = $(this).prev(); console.log('$prev ==> ', $prev); var text = $prev.text(); console.log('text ==> ', text); $('#username').val(text); $('.box').show(); })
$('#save').click(function () { var username = $('#username').val(); console.log('username ==> ', username); $prev.text(username); $('#username').val(''); $('.box').hide(); })
$('#cancel').click(function () { $('#username').val(''); $('.box').hide(); }) </script> </body>
</html>
|
代码部分:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| <!DOCTYPE html> <html lang="en">
<head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> .tab { display: flex; background-color: #ddd; width: 800px; margin: 0 auto; }
.tab-item { width: 160px; height: 40px; line-height: 40px; font-size: 14px; color: #444; text-align: center; cursor: pointer; }
.tab-item.active { background-color: #e4393c; color: #fff; } </style> </head>
<body>
<div class="tab"> <div class="tab-item active">商品介绍</div> <div class="tab-item">规格与包装</div> <div class="tab-item">售后保障</div> <div class="tab-item">商品评价(50000)</div> <div class="tab-item">手机社区</div> </div>
<script src="./js/jquery-3.7.1.min.js"></script> <script>
$('.tab-item').click(function () {
$(this).addClass('active').siblings('.active').removeClass('active');
}) </script> </body>
</html>
|
代码部分:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| <!DOCTYPE html> <html>
<head> <meta charset="utf-8"> <title>荆雪の标题w-</title> <link rel="stylesheet" type="text/css" href="./style/default.css" /> </head>
<body> <div class="king"> <ul> <li class="current"> <div class="small red1"></div> <div class="big red2"></div> </li> <li> <div class="small orange1"></div> <div class="big orange2"></div> </li> <li> <div class="small yellow1"></div> <div class="big yellow2"></div> </li> <li> <div class="small green1"></div> <div class="big green2"></div> </li> <li> <div class="small blue1"></div> <div class="big blue2"></div> </li> <li> <div class="small pink1"></div> <div class="big pink2"></div> </li> <li> <div class="small purple1"></div> <div class="big purple2"></div> </li> </ul> </div>
<script src="./js/jquery-3.7.1.min.js"></script> <script> $(".king li").mouseenter(function () { $(this).stop().animate({ width: 224 }).find(".small").stop().fadeOut().siblings(".big").stop().fadeIn(); $(this).siblings("li").stop().animate({ width: 69 }).find(".small").stop().fadeIn().siblings(".big").stop().fadeOut(); }); </script>
</body>
</html>
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
| * { margin: 0; padding: 0; }
.king { width: 709px; margin: 100px auto; background-color: #1E4D75; overflow: hidden; padding: 10px; border-radius: 10px; }
.king ul { list-style: none; }
.king li { position: relative; float: left; width: 69px; height: 69px; margin-right: 10px; }
.king li.current { width: 224px; }
.king li.current .big { display: block; }
.king li.current .small { display: none; }
.big { width: 224px; height: 69px; display: none; border-radius: 5px; }
.small { position: absolute; top: 0; left: 0; width: 69px; height: 69px; border-radius: 5px; }
.red1 { background: #FF3333; }
.red2 { background: #CC0000; }
.orange1 { background: #FFBB66; }
.orange2 { background: #FF8800; }
.yellow1 { background: #FFFFBB; }
.yellow2 { background: #FFFF77; }
.green1 { background: #99FF99; }
.green2 { background: #66FF66; }
.blue1 { background: #00BBFF; }
.blue2 { background: #0066FF; }
.pink1 { background: #FF88C2; }
.pink2 { background: #FF44AA; }
.purple1 { background: #E93EFF; }
.purple2 { background: #CC00FF; }
|