//縮略圖
<div id="one">
<img src="web1904/img/hw1/1-1.jpg">
</div>
<div id="two">
<img src="web1904/img/hw1/1-2.jpg" id='1'>
<img src="web1904/img/hw1/2-2.jpg" id='2'>
<img src="web1904/img/hw1/3-2.jpg" id='3'>
</div>
<script type="text/javascript">
let imgs1 = document.querySelector('#one>img')
let imgs2 = document.querySelectorAll('#two>img')
for (img of imgs2){
img.addEventListener('click', function(evt) {
imgs1.src= web1904/img/hw1/${evt.target.id}-1.jpg
})
}
//點擊
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
button {
border: none;
outline: none;
width: 120px;
height: 30px;
font: 16px/30px "courier new";
color: white;
background-color: red;
margin: 10px 20px;
cursor: pointer;
}
</style>
</head>
<body>
<button><input type="checkbox">A</button>
<button><input type="checkbox">B</button>
<button><input type="checkbox">C</button>
<button><input type="checkbox">D</button>
<button><input type="checkbox">E</button>
<script>
let buttons = document.getElementsByTagName('button')
let count = 1
for (button of buttons) {
button.addEventListener('click', (evt) => {
if (count % 2 ){
evt.target.style.backgroundColor = 'green';
evt.target.childNodes[0].checked = true
}else{
evt.target.style.backgroundColor = 'red';
evt.target.childNodes[0].checked = false
}
count+=1
})
}
</script>
</body>
</html>
2019-08-26作業
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
推薦閱讀更多精彩內容
- 源站:http://fengyuanchen.github.io/viewer/ 應用: html: 源碼上是正常...
- 第3章 基本概念 3.1 語法 3.2 關鍵字和保留字 3.3 變量 3.4 數據類型 5種簡單數據類型:Unde...