Case 1: Select all
Application knowledge points: ondblclick=() | onclick | Find tag attributes, judgments and functions applications
<!DOCTYPE%20html><html>%20%20<head>%20%20%20%20<meta%20charset="UTF-8">%20%20%20%20<title></title>%20%20</head>%20%20<body>%20%20%20%20<div>%20%20%20%20%20%20%20%20<input%20type="button"%20value="Select all"%20ondblclick="checkAll()"%20/ >%20%20%20%20%20%20%20<input%20type="button"%20value="Cancel"%20ondblclick="cancleAll()"%20/>%20%20%20%20%20%20%20%20%20<input%20type="button"%20value="undelect"%20ondblclick="reverseAll()"%20/>%20%20%20%20%20%20 %20<thead>%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 %20%20%20%20<tbody%20id="tb">%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 0%20%20%20%20%20%20%20</tr>%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20% 20%20%20%20%20</tr>%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 %20%20</tr>%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2 0%20</tr>%20%20%20%20%20%20</tbody>%20%20%20</table>%20%20%20%20%20<script>%20%20%20%20%20%20//If you select all, first get all input tag attributes, and then all are true%20%20%20%20%20%20%20 function%20checkAll(){%20%20%20%20%20%20%20%20var%20tb%20=%20document.getElementBy Id('tb');//Get tb, that is, body%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20(var%20i=0;i<checks.length;%20i++){%20%2 0%20%20%20%20%20%20%20%20%20%20var%20current_check%20=%20checks[i];//Get the value of each input and assign a variable name%20%20%20%20%20%20%20%20%20%20%20%20%20%20 function%20canc leAll(){%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20//[First, 2, 3, 4, 5] checked%20=%20true%20 %20%20%20%20%20%20%20%20%20 for%20(var%20i=0;i<checks.length;%20i++){%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 %20%20%20%20%20}%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20tb%20=%20document.getElementById('tb');//Get tb, that is, body%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20checks%20=%20tb.ge tElementsByClassName('c1');%20%20%20%20%20%20%20%20%20%20//[First, 2, 3, 4, 5]checked%20=%20true%20%20%20%20%20%20%20%20%20checks[i];//Get each inp ut value and assign a variable name %20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 %20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20</body></html>Case 2: Single choice
You can only choose one, and use js to change its options
Application knowledge points: getElementsByTagName%20|%20checked%20|%20mutex
<!DOCTYPE%20html><html>%20%20<head>%20%20%20%20<meta%20charset="UTF-8">%20%20%20%20<title></title>%20%20</head>%20%20<body>%20%20%20%20<ul>%20%20%20%20%20%20%20%20%20<li><input%20type="radio"%20name="g"%20value="11"%20/>Male</li>%20%20%20%20%20%20%20%20%20<l i><input%20type="radio"%20name="g"%20value="22"%20/>Female</li>%20%20%20%20%20%20%20%20<!--radio%20=%20document.getElementsByTagName('input')%20%20%20%20%20[<inp ut%20type="radio"%20name="g"%20value="11">,%20<input%20type="radio"%20name="g"%20value="11">,%20<input%20type="radio"%20name="g"%20value="11">]%20%20%20%20%20radio[1]%20%20%20%20%20%20<input%20type="radio"%20name="g"%20value="11"> %20%20%20%20xo%20=%20radio[1]%20%20%20%20%20<input%20type="radio"%20name="g"%20value="11">%20%20%20%20%20%20%20%20xo.value%20%20%20%20%20%20xo.checked%20%20%20%20false%20%20%20xo.checked%20=%20true%20%20%20%20true-->%20%20</body></html>Case 3: Cloning
<!DOCTYPE%20html><html>%20%20<head>%20%20%20%20<meta%20charset="UTF-8">%20%20%20%20<title></title>%20%20</head>%20%20<body>%20%20%20%20<h2%20id="h1">333%20%20%20%20%20%20<span>123</span>%20%20%20%20%20%20%20%20%20<span>123</span>%20%20%20%20%20%20%20%20%20%20%20<span>123</span>%20%20%20%20%20%20%20%20%20%20<span>123</span>%20%20%20%20%20%20%20%20%20%20 0%20%20%20<a>123</a>%20%20%20%20</h2>%20%20%20%20%20<div%20id="container">%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20% 20</div>%20%20%20%20%20<script>%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 //c.appendChild(h);//It is directly added to 2//%20%20%20%20%20%20var%20newH%20=%20h.cloneNode(true);//No true, only cloning format//%20%20%20%20c.appendChild(newH); After adding true, it is completely cloned to 2%20%20%20%20</script>%20%20</body></html>
Case 4: Custom attributes, get custom attributes and change the tag content
<!DOCTYPE%20html><html>%20%20<head>%20%20%20%20<meta%20charset="UTF-8">%20%20%20%20%20<title></title>%20%20</head>%20%20<body>%20%20%20%20%20%20%20%20//A selector can be constructed %20%20%20%20%20// %20%20%20%20%20<input%20type="button"%20onclick="Func()"%20value="Click me"%20/>%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20% 20<div%20class="c1"%20alex='sb'>123</div>%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20<div%20c lass="c1">123</div>%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20<div%20class="c1"%20alex='sb'>123</div>%20 %20%20%20%20%20<div%20class="c1">123</div>%20%20%20%20</div>%20%20%20%20%20<script>%20%20%20%20 function%20Func(){%20%20%20%20%20%20//i1All children, loop each child, judge if alex='sb'%20%20%20%20%20%20var%2 0i1%20=%20document.getElementById('i1')%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 for%20(%20var%20i%20=0;%20i<divs.length;i++){%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 cur rent_div%20=%20divs[i];%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20(r esult%20==%20'sb'){%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20}%20%20%20%20%20%20}%20%20%20%20%20}%20%20%20%20</script>%20%20</body></html>Case 5: Three ways to get the values in the input box
<!DOCTYPE%20html><html><head>%20%20<title></title>%20%20<meta%20charset="utf-8"%20/></head><body>%20%20<div%20id="inp">%20%20%20%20%20</div>%20</div>%20 %20<input%20type="text"%20class="aa"/>%20%20<input%20type="button"%20value="add"%20onclick="Func();"%20/>%20%20</div>%20%20<div%20id="lis">%20%20%20%20 %20<ul>%20%20%20%20%20%20%20<li>Braised pork</li>%20%20%20%20%20%20<li>Braised elbow</li>%20%20%20%20%20<li>Braised fish</li>%20%20%20</ul>%20%20</div>%20%20<script>%20%2 0%20%20var%20inp_aa%20=%20document.getElementsByClassName('aa');%20%20%20%20inp_aa[0].value%20=%20'Braised Hairfish';//Equivalent to entering content %20%20 in the input box</script></body></html> <!DOCTYPE%20html><html><head>%20%20<title></title>%20%20<meta%20charset="utf-8"%20/></head><body>%20%20<div%20id="inp">%20%20%20%20</div>%20%20<input%20type="text"%20class="aa"/>%20%20<input%20type="button"%20value="Add"%20onclick="Func();"%20/>%20%20</div>%20%20<div%20id="lis">%20%20%20<div%20id="lis">%20%20%20<div%20id="lis">%20%20%20 %20%20<ul>%20%20%20%20%20%20%20%20<li>Braised pork</li>%20%20%20%20%20%20<li>Braised elbow</li>%20%20%20%20</div>%20%20%20<script>% 20%20%20%20var%20c%20=%20document.querySelector('.aa');//Query selector%20. is the distinction id, the syntax of the tag%20%20%20c.value%20=%20'Braised Eggplant';%20%20%20%20</script></body></html>Method 2: Query
<!DOCTYPE%20html><html><head>%20%20<title></title>%20%20<meta%20charset="utf-8"%20/></head><body>%20%20<div%20id="inp">%20%20%20%20</div>%20%20<input%20type="text"%20id="aa"/>%20%20<input%20type="button"%20value="add"%20onclick="Func();"%20/>%20%20</div>%20%20<div%20id="li s">%20%20%20%20<ul>%20%20%20%20%20%20%20<li>Braised pork</li>%20%20%20%20%20%20<li>Braised elbow</li>%20%20%20%20%20</ul>%20%20</div>%20%20%20<script>%20%20%20%20var%20c%20=%20document.getElementById('aa');%20%20%20%20c.value%20=%20'Braised Eggplant';%20%20%20%20%20</script></body></html>Method 3: id
Case 6:
%20//'beforeBegin', 'afterBegin'/%20'beforeEnd'/'afterEnd'
<!DOCTYPE%20html><html>%20%20<head>%20%20%20%20<title></title>%20%20%20%20<meta%20charset="utf-8"%20/>%20%20</head>%20%20%20<body>%20%20%20%20<div%20id="inp">%20%20%20%20</div>%20%20%20%20<input%20type="text"%20/>%20%20%20%20%20<input%20type="button"%20value="add"%20onclick="addElen(this)" %20/>%20%20%20%20</div>%20%20%20%20%20%20<div>%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20<li>Braised Pork</li>%20%20%20%20%20%20%20<li>Braised Elbow< /li>%20%20%20%20%20%20%20%20%20%20<li>Braised Fish</li>%20%20%20%20%20%20</ul>%20%20%20%20%20</div>%20%20%20%20%20%20%20%20%20 function%20 addElen(ths)%20{%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20aaa%20=%20ths.previousElementSibling.value;%20%20%20%20%20%20%20al ert(aaa)%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20arert(lis t_li)%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 %20%20%20%20%20%20%20%20%20list_li.insertAdjacentHTML("beforEnd",%20bbb)%20%20%20%20%20%20%20%20}%20%20%20</script>%20%20</body></html> <!DOCTYPE%20html><html>%20%20<head>%20%20%20%20<title></title>%20%20%20%20<meta%20charset="utf-8"%20/>%20%20</head>%20%20%20<body>%20%20%20%20<div%20id="inp">%20%20%20%20</div>%20%20%20%20%20<input%20type="text"%20/>%20%20%20%20%20<input%20type="button"%20value="add"%20on click="addElen(this)"%20/>%20%20%20%20</div>%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 t>%20%20%20%20%20%20%20%20 function%20addElen(ths){%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20document_li%20=%20document.getElementById("lis");%20//get ul%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 tag%20=%20document t.createElement('li');//Create li%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20list_li.insertBefore(tag,%20list_li.children[-1])//Insert the value of the required position according to the index %20%20%20%20}%20%20%20</script>%20%20</body></html> <!DOCTYPE%20html><html>%20%20<head>%20%20%20%20<meta%20charset="UTF-8">%20%20%20%20<title></title>%20%20</head>%20%20<body>%20%20%20%20<div>%20%20%20%20%20%20%20%20<input%20type="text"%20/>%20%20%20%20%20%20%20%20<input%20type="but ton"%20value="Add"%20onclick="AddElement(this)"%20/>%20%20%20%20</div>%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 </ul>%20%20%20%20</div>%20%20%20%20%20%20<script>%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2 0%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20//'beforeB eggin', 'afterBegin'/%20'beforeEnd'/'afterEnd'%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20//afterBegin%20 Internal close-fitting%20%20%20%20%20%20%20%20%20//afterEnd%20 External close-fitting//%20 %20%20%20%20%20%20%20%20%20commentList.insertAdjacentHTML("beforEnd",%20str)%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tag.innerText%20=%20document.createElement('li');%20%20%20%20%20%20%20%20tag.innerText%20=% 20val;%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 tag.app endChild(temp);%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 console.log(commentList.children[1])%20%20%20%20%20}%20%20%20</script>%20%20</body>%20%20</html>Case 7:
<!DOCTYPE%20html><html>%20%20<head>%20%20%20%20<meta%20charset="UTF-8">%20%20%20%20%20%20height:%2040px;%2040px;%2040px;%2040px;%2040px;%2040px;%20%20%20%20%20height:%2040px;%2 0%20%20%20%20%20}%20%20%20%20%20%20%.gg{%20%20%20%20%20%20%20%20%20%20%20}%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 %20%20</style>%20%20</head>%20%20<body>%20%20%20%20%20%20%20<p>When the mouse enters Yes, remove the content</p>%20%20%20%20<p>When the input table exits, add the content</p>%20%20%20%20<input%20type="text"%20class="gg"%20value="Please enter the content"%20onfocu s="Focus(this)"%20onblur="Blur(this)"%20/>%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20//The first way to find%20%20%20%20%20%20%20%20//document. . %20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 %20if%20(current_val%20==%20"Please enter content"){%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 %20%20%20function%20Blur(ths)%20{%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20(current_val%20==%20"Please enter content"%20||%20current_val.trim().length%20==%200%20){ %20%20%20%20%20%20%20%20%20%20%20%20ths.value%20=%20'Please enter the content';%20%20%20%20%20%20%20%20%20%20%20%20%20%20}%20%20%20%20%20%20%20}%20%20%20%20%20</script>%20%20</body></html>Case 8: Head menu
<!DOCTYPE%20html><html>%20%20<head>%20%20%20%20<title></title>%20%20%20%20%20<meta%20charset="utf-8"%20/>%20%20%20%20%20%20%20%20%20.pg_top%20.menu%20{%20%20%20%20%20%20%20%20%20background-colo r:%20gold;%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2 0%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20font-size:% 2025px;%20%20%20%20%20%20}%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 0%20%20%20%20%20%20%20background-color:%20burlywood;%20%20%20%20%20%20%20%20%20%20%20%20%20.hide%20{%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%.hide%20{%20%2 0%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20</style>%20%20%20%20%20 </head>%20%20<body>%20%20%20%20%20<div%20class="pg_top">%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 %20%20<div%20class="item"%20con="h2"%20onclick="Show(this)">Guijie</div>%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20<d iv%20id="content"%20class="content">%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20<div%20class="hide"%20c on="h3">Meet the bar</div>%20%20%20%20%20%20</div>%20%20%20%20</div>%20%20%20%20%20%20<script>%20%20%20%20%20%20 function%20Show(ths)%20{%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20% 0baba%20=%20ths.parentElement.children;%20//Get each child element %20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 for%20(i%20=%200;%20i%20<%20baba.length;%20i++)%20{%2 0%20%20%20%20%20%20%20%20%20%20%20 if%20(ths%20==%20baba[i])%20{%20//Make a judgment, %20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20% 20%20%20%20%20baba[i].classList.remove('bk')%20//Remove attributes%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20//Content%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20current_con%20=%20document.get ElementById('content').children;%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 for%20(j=0;%20j<current_con.length;j++)%20{%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20s_att%20=%20cur rent_con[j].getAttribute('con')%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20% 20}else{%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20}%20%20%20%20%20%20%20}%20%20%20</script>%20%20</body></html> <!DOCTYPE%20html><html>%20%20<head>%20%20%20%20<meta%20charset="UTF-8">%20%20%20%20%20%20<title></title>%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20% 0;%20%20%20%20}%20%20%20%20ul%20li{%20%20%20%20%20%20%20%20%20%20}%20%20%20%20%20%20%20%20 color:%20white;%20%20%20%20%20%20%20%20%20%20%20padding:%208px%2010px;%20%20%20%20%20%20}%20%20%20%20%20.clearfix:after{%2 0%20%20%20%20%20display:%20block;%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2 0%20%20%20.hide{%20%20%20%20%20%20%20%20}%20%20%20%20%20%20%20%20%20%.tab-menu%20.title{%20%20%20%20%20%20%20%20%20%20%20%20.tab-menu%20.title{%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20.tab-menu%20.title%20.active{%20%20%20%20%20%20%2 0%20%20background-color:%20white;%20%20%20%20%20%20%20%20%20}%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20border:%201px%20solid%20#dddddd;%20%20%20%20%20min-height:%20150px;%20%20%20%20%20%20}%20 %20</style>%20%20</head>%20%20<body>%20%20%20%20<div%20style="width:400px;%20margin:%200%20auto;">%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 >%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 0target='h3'%20onclick="Show(this)">Tianshahai</li>%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20<div%20con="h1">Baked lamb legs</div>%20 %20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20% 20%20</div>%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20<script>%20%20%20%20%20%20%20 function%20Show(ths){%20%20%20%20%20%20%20%20%20%20%20//ths indicates the current tag%20%20%20%20%20%20%20%20var%20target%20=%20ths.getAttribute('target')//h3%20%20%20%20 %20%20%20%20%20//Add yourself style active%20%20%20%20%20%20%20%20%20%20%20%20ths.className%20=%20'active';%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20brothers%20=%20ths.parentElement.children;%20%20%20%20%20%20%20%20%20 for(var%20i=0;i<br others.length;i++){%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20brothers[i].removeAttribute('class')%20 %20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20console.log(co tents)%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 var%20con%20=%20current_content.getAttribute('con')%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20% 20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20</script>%20%20</body></html>Case 9: Return to the top
Main knowledge points: onscroll%20 and document.body.scrollTop;
<!DOCTYPE%20html><html>%20%20<head>%20%20%20%20<meta%20charset="UTF-8">%20%20%20%20%20%20<title></title>%20%20%20%20%20%20%20%20%20.go-top{%20%20%20%20%20%20position:%20fixed;%20%20%20%20%20%20%20position:%20fixed;%20%20%20%20%20%20%20position:%20fixed;%20%20%20%20%20%20%20position:%20fixed;%20%20%20%20%20%20%20%20position:%20fixed;%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2 0%20%20%20%20%20%20right:%2020px;%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 background-color:%20dar kgoldenrod;%20%20%20%20%20%20%20%20%20 color:%20white;%20%20%20%20%20%20%20}%20%20%20%20%20%20%20%20%20%20<b ody%20onscroll="Func();">%20%20%20%20%20<div%20id="i1"%20style="height:%202000px;%20background-color:%20greenyellow;">%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20</div>%20%2 0%20%20<div%20id="i2"%20class="go-top%20hide">%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20% 20%20function%20Func(){%20%20%20%20%20%20%20%20%20%20%20var%20scrollTop%20=%20document.body.scrollTop;//body's scroll height%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 %20if(scrollTop>100){%20%20%20%20%20%20%20%20%20%20%20ii.classList.remove('hide');//Remove it to display %20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 %20}%20%20%20%20%20%20%20}%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20}%20%20%20%20</script>%20%20</body></html>Case 10:
Main knowledge points:
//scroll%20 scroll; the meaning of scroll
//%20scrollTop:%20 scrollbar height from top
//%20scrollHeight:%20 Document height: itself + padding
//%20clientTop:%20 border height
//%20clientHeight:%20 The current range visible height: itself%20+%20padding
//offset%20 printing meaning
//%20offsetTop:%20 The height of the current label from "top" (body)
//%20 If there is no post in his previous level, if there is, the position tag is mainly based on the position tag.
//%20offsettHeight:%20 The height of its own range: itself + padding + border
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <div style="height: 20px;background-color: green;"></div><!--head--> <div style="border: 5px solid pink;padding: 10px;"><!--body--> <div> <div id="xo" style="height: 200px;overflow: auto;width: 400px;margin: 0 auto;border: 15px solid red;padding: 3px;" > <div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div> <div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div> <div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div> <div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div><div>sdf</div> <div>sdf</div> <div>sdf</div> </div> </div> </div> </div> </div> <script> var ii = document.getElementById('xo') console.log(ii.scrollTop) console.log(ii.scrollHeight) console.log(ii.clientTop) console.log(ii.clientHeight) console.log(ii.offsetTop) console.log(ii.offsetHeight) //scroll Scroll; scroll meaning // scrollTop: scrollbar height from the top // scrollHeight: Document height: itself + padding// clientTop: border height // clientHeight: visible range height: itself + padding //offset Print meaning // offsetTop: The current label distance from the "top" (body)// If there is no post on the previous level, if there is one, the position label is mainly used // offsetHeight: The visible range height: itself + padding+border </script> </body></html>Okay, I'll introduce it here for the time being. I hope everyone will write more and practice more, mainly the logic. Of course, many people are starting to use jquery now, so everyone should pay more attention.