简单方法把鼠标变成胡桃摇

简单方法把鼠标变成胡桃摇


代码

document.body.appendChild(document.createElement('img')).id = "img1";
        var pic = document.querySelector('#img1');
        document.addEventListener('mousemove', function (e) {pic.src = "https://upload-bbs.mihoyo.com/upload/2021/12/06/175584021/a8d2f0687f74dfbef9f654fb8da3d12a_7341983145053981094.gif?x-oss-process=image/auto-orient,0/interlace,1/format,gif";pic.style.height="80px";pic.style.width = "80px";pic.style.left = e.pageX - 40 + 'px';pic.style.top = e.pageY - 40 + 'px';pic.style.position = 'absolute';pic.style.cursor = 'none';pic.style.zIndex = '999';})

f12打开控制台,把代码粘贴上去回车运行

ps:恢复的话只需要刷新一下页面即可。

你可能感兴趣的:(html5,javascript,css)