获得徽章 0
#新人报道# disabled伪元素
<!DOCTYPE html>
<head>
<style>
.btn{
background-color:blue;
height: 100px;
width: 168px;
}
.btn:disabled{
background-color: aqua;
}
</style>
</head>
<body>
<button id="btnId" class="btn">伪元素</button>
<script>
document.getElementById("btnId")
.addEventListener("click", (e) => {
e.target.setAttribute("disabled", "true")
});
</script>
</body>
</html>
<!DOCTYPE html>
<head>
<style>
.btn{
background-color:blue;
height: 100px;
width: 168px;
}
.btn:disabled{
background-color: aqua;
}
</style>
</head>
<body>
<button id="btnId" class="btn">伪元素</button>
<script>
document.getElementById("btnId")
.addEventListener("click", (e) => {
e.target.setAttribute("disabled", "true")
});
</script>
</body>
</html>
展开
评论
1
#新人报道# 对象的深拷贝和浅拷贝
function clone(object, deep) {
if (object === null || typeof object !== "object") {
return object;
}
var result = new object.constructor();
for (var propertyName in object) {
if (object.hasOwnProperty(propertyName)) {
var value = object[propertyName];
if (deep) {
value = clone(value, deep);
}
result[propertyName] = value;
}
}
return result;
}
function clone(object, deep) {
if (object === null || typeof object !== "object") {
return object;
}
var result = new object.constructor();
for (var propertyName in object) {
if (object.hasOwnProperty(propertyName)) {
var value = object[propertyName];
if (deep) {
value = clone(value, deep);
}
result[propertyName] = value;
}
}
return result;
}
展开
评论
2
![[微笑]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_1.7d9f699.png)
![[流泪]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_6.dde0d83.png)
![[吐彩虹]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_94.f9c84dc.png)
![[碰拳]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_114.4b8db8b.png)
![[做鬼脸]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_62.d7ca811.png)