楼主: 凡哥

[日记] JS代码点滴

[复制链接]
 楼主| 发表于 2024-8-10 12:00 | 显示全部楼层

到了到了
点评
回复

使用道具

发表于 2024-8-10 12:49 | 显示全部楼层

这句话太经典,不管是倒装乱字,人脑就会自动归位
点评
回复

使用道具

 楼主| 发表于 2024-8-10 17:38 | 显示全部楼层
花简静 发表于 2024-8-10 12:49
这句话太经典,不管是倒装乱字,人脑就会自动归位

挺好的
点评
回复

使用道具

发表于 2024-8-10 20:04 | 显示全部楼层
<div id="rBox">结果</div>   <script> txtReverse = str => str.split('').reverse().join(''); rBox.innerText = txtReverse('上海自来水来自海上'); </script>  
点评
回复

使用道具

发表于 2024-8-10 20:06 | 显示全部楼层
结果:上海自来水来自海上

本来想发完就跑的,现在连个跑的图标都找不到。今天又卡得怀疑人生。。
点评
回复

使用道具

发表于 2024-8-10 20:07 | 显示全部楼层
本帖最后由 花简静 于 2024-8-10 20:13 编辑

重复贴子,编了。。
点评
回复

使用道具

发表于 2024-8-10 20:08 | 显示全部楼层
跑一个
点评
回复

使用道具

 楼主| 发表于 2024-8-12 08:07 | 显示全部楼层
十六进制颜色配色工具

ff

ff

ff

评分

1

查看全部评分

点评
回复

使用道具

 楼主| 发表于 2024-8-12 08:09 | 显示全部楼层

2024年8月12日 星期一

上楼效果代码

<style>
.pa {
	margin: 30px auto;
	width: fit-content;
	height: fit-content;
}
#mydiv {
	margin-bottom: 20px;
	width: 600px;
	height: 300px;
	border: 1px solid gray;
	background: #fff;
	color: #ffff00;
	font: normal 2em sans-serif;
	text-shadow: 1px 1px 2px #111;
	display: grid;
	place-items: center;
}
</style>

<div class="pa">
	<div id="mydiv">十六进制颜色配色工具</div>
	<p>
		<label for="rng1">红色 :</label>
		<input id="rng1" class="rng" type="range" value="255" min="0" max="255" />
		<output class="op">ff</output>
	</p>
	<p>
		<label for="rng2">绿色 :</label>
		<input id="rng2" class="rng" type="range" value="255" min="0" max="255" />
		<output class="op">ff</output>
	</p>
	<p>
		<label for="rng3">蓝色 :</label>
		<input id="rng3" class="rng" type="range" value="255" min="0" max="255" />
		<output class="op">ff</output>
	</p>
</div>

<script>
var rngs = document.querySelectorAll('.rng'), ops = document.querySelectorAll('.op');
add0 = (str) => str.length < 2 ? str.padStart(2,'0') : str;
rngs.forEach((rng,key) => rng.oninput = () => {
	ops[key].value = add0(parseInt(rng.value).toString(16));
	mydiv.textContent = mydiv.style.background = `#${ops[0].value}${ops[1].value}${ops[2].value}`;
});
</script>

评分

1

查看全部评分

点评
回复

使用道具

发表于 2024-8-12 11:20 | 显示全部楼层
感觉看到滑竿没那么怕了。。
还是要仔细研究一下代码,不知道能不能看懂
点评
回复

使用道具

您需要登录后才可以回帖 登录 | 中文注册

本版积分规则

手机版|千山论坛 ( 冀ICP备2024055714号 )

GMT+8, 2025-9-15 17:25

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表