그래서 먼저 내 문제를 설명하고 싶었습니다.
내 웹사이트에 일반 마우스/포인터와 레고 손을 커서로, 머리를 포인터로. 그러나 스위처를 클릭할 때만 커서가 표시되도록 할 수 있습니다. 이 포인터를 어떻게 추가할 수 있습니까?
(커서: url(), 포인터;)
다음 클래스에 할당해야 합니다.
a, 버튼, 입력, 입력, 버튼, a, 입력, .slider, .round
또한 스위처/체크박스가 선택된 상태로 유지되도록 하는 스니펫을 추가했습니다... (이 비디오 [비밀번호는 12345678]에서 볼 수 있습니다. https://easyupload.io/gknxoi)
그러나 예를 들어 페이지를 새로고침한 후 스위처는 선택된 상태로 유지되지만 커서는 표시되지 않습니다...
누군가가 나를 도울 수 있기를 바랍니다!!!
< script > var cbs= document.querySelectorAll('input[type=checkbox]');
for (var i= 0; i < cbs.length; i++) {
cbs[i].addEventListener('change', function() {
if (this.checked) {
document.body.style.cursor=
"url(https://cdn.shopify.com/s/files/1/0571/7137/8349/files/cursor.png?v=1644096068), auto";
} else {
document.body.style.cursor= "default";
}
});
}
$(function() {
var test= localStorage.input=== 'true' ? true : false;
$('input').prop('checked', test || false);
});
$('input').on('change', function() {
localStorage.input= $(this).is(':checked');
console.log($(this).is(':checked'));
});
< /script>
.switcheronheader {
position: relative;
display: inline-block;
width: 30px;
height: 17px;
margin-bottom: 2px;
}
.mouseswitcher {
/* border-left: 1px solid #248751; */
padding-left: 20px;
}
.switcheronheader input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 13px;
width: 13px;
left: 2px;
bottom: 2px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked+.slider {
background-color: #248751;
}
input:focus+.slider {
box-shadow: 0 0 1px #2196F3;
}
input:checked+.slider:before {
-webkit-transform: translateX(13px);
-ms-transform: translateX(13px);
transform: translateX(13px);
}
.slider.round {
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;
}
<div class="mouseswitcher"> <label class="switcheronheader"> <input type="checkbox" id="overheaderswitch"> <span class="slider round"></span> </label> </div>