“星级”按预期工作https://codepen.io/462960/pen/WZXEWd但每次点击后页面都会跳动。 我试图阻止它
const labels = document.querySelectorAll('label');
function noDefault(e){
e.preventDefault();
};
labels.forEach(x => x.addEventListener('click', noDefault));
但这不是理想的解决方案,因为它会阻止检查输入。我无法在网页中使用。任何建议表示赞赏。
最佳答案
解决方案:隐藏标签的输入
&:not(:checked) {
> input {
display: none;
//position: absolute;
//top: -9999px;
clip: rect(0,0,0,0);
}
关于javascript - 防止页面在检查输入时突然跳动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46567078/