当前位置:网站首页>Web APIs exclusivity
Web APIs exclusivity
2022-07-03 05:04:00 【The wind blows and birds fly in the crotch】
Exclusive thoughts :

If you have the same set of elements , We want an element to implement a certain style , Need to use the exclusive thought algorithm of the loop :
All elements clear the style ( Kill the others )
Style the current element ( Leave me alone )
Note that the order cannot be reversed , First kill the others , Set yourself up
<button> Button 1</button>
<button> Button 2</button>
<button> Button 3</button>
<button> Button 4</button>
<button> Button 5</button>
<script>
// 1. Get all button elements
var btns = document.getElementsByTagName('button');
// btns The result is a pseudo array Every element in it btns[i]
for (var i = 0; i < btns.length; i++) {
btns[i].onclick = function() {
// (1) Let's remove all the button background colors first Get rid of everyone
for (var i = 0; i < btns.length; i++) {
btns[i].style.backgroundColor = '';
}
// (2) Then let the current element background color be pink Leave me alone
this.style.backgroundColor = 'pink';
}
}
</script>
边栏推荐
- Preparation for school and professional cognition
- Compile and decompile GCC common instructions
- Go language interface learning notes Continued
- "Niuke brush Verilog" part II Verilog advanced challenge
- 并发操作-内存交互操作
- [SQL injection] joint query (the simplest injection method)
- String matching: find a substring in a string
- MediaTek 2023 IC written examination approved in advance (topic)
- 文献阅读_基于多模态数据语义融合的旅游在线评论有用性识别研究(中文文献)
- Wechat applet distance and map
猜你喜欢

leetcode452. Detonate the balloon with the minimum number of arrows

Shallow and first code

Unity tool Luban learning notes 1

5-36v input automatic voltage rise and fall PD fast charging scheme drawing 30W low-cost chip

音频焦点系列:手写一个demo理解音频焦点与AudioMananger

LVS load balancing cluster of efficient multi-purpose cluster (NAT mode)

Shuttle + Alluxio 加速内存Shuffle起飞

The programmer resigned and was sentenced to 10 months for deleting the code. JD came home and said that it took 30000 to restore the database. Netizen: This is really a revenge

JDBC database operation

2022-02-12 daily clock in: problem fine brush
随机推荐
1115 counting nodes in a BST (30 points)
Class loading mechanism (detailed explanation of the whole process)
论文阅读_中文NLP_ELECTRA
Unity tool Luban learning notes 1
[tools run SQL blind note]
Current market situation and development prospect forecast of global UV sensitive resin 3D printer industry in 2022
2022-02-11 daily clock in: problem fine brush
Online VR model display - 3D visual display solution
Basic knowledge of reflection (detailed explanation)
Ueditor, FCKeditor, kindeditor editor vulnerability
Objects. Requirenonnull method description
112 stucked keyboard (20 points)
1095 cars on campus (30 points)
Oracle SQL table data loss
[set theory] relation properties (transitivity | transitivity examples | transitivity related theorems)
Uipath practice (08) - selector
Notes | numpy-09 Broadcast
Shell script -- condition judgment
50 practical applications of R language (36) - data visualization from basic to advanced
Source insight garbled code solution