我正在使用JavaScript创建自定义鼠标指针,因此我想在.focus
事件的HTML文档中的某个元素上添加类(mouseover
),并在{{1}上将其删除}事件。
mouseout
这是焦点事件在HTML文档中某些元素上的功能,其中鼠标指针会更改在CSS const cursor1 = document.querySelector('.cursor1'); // here we can select the cursor class div
if (is_touch_device() == false) {
document.addEventListener('mousemove',e => {
cursor1.setattribute("style","top:" + (
e.pageY - 15) + "px;left:" + (
e.pageX - 15) + "px;")
document.addEventListener('click',() => {
cursor1.classList.add("expand");
setTimeout(() => {
cursor1.classList.remove("expand");
},450);
});
});
}
window.onload = function() {
if (is_touch_device()) {
cursor1.setattribute("style","display:none")
}
}
function is_touch_device() {
return !!('ontouchstart' in window) // works on most browsers
|| !!('onmsgesturechange' in window); // works on ie10
};
类中定义的颜色和大小,我想在.hover
和{{ 1}}事件
mouseover