• 鼠标简单跟随提示二


    Js代码 复制代码 收藏代码
    1. function id(s){
    2. return document.getElementById(s);
    3. }
    4. /**
    5. * 鼠标跟随提示
    6. */
    7. function mouseFollow() {
    8. var e = e ? e : window.event;
    9. var posx = e.clientX;
    10. var posy = e.clientY;
    11. var followDiv = id("followDiv") ? id("followDiv"): document.createElement("div");
    12. followDiv.setAttribute("id","followDiv");
    13. var css = "100px;height:20px;border:1px solid grey;position:absolute;z-index:10000;left:"+posx+";top:"+posy+";";
    14. setCss(followDiv,css);
    15. document.body.appendChild(followDiv);
    16. }
    17. /**
    18. * element:需要获取样式的目标元素;name:样式属性
    19. */
    20. function getStyle(element, name) {
    21. var computedStyle;
    22. try {
    23. computedStyle = document.defaultView.getComputedStyle(element, null);
    24. } catch (e) {
    25. computedStyle = element.currentStyle;
    26. }
    27. if (name != "float") {
    28. return computedStyle[name];
    29. } else {
    30. return computedStyle["cssFloat"] || computedStyle["styleFloat"];
    31. }
    32. }
    33. /**
    34. * element:需要设置样式的目标元素;name:样式属性;value:设置值
    35. */
    36. function setStyle(element, name, value) {
    37. if (name != "float") {
    38. element.style[name] = value;
    39. } else {
    40. element.style["cssFloat"] = value;
    41. element.style["styleFloat"] = value;
    42. }
    43. }
    44. /**
    45. *
    46. */
    47. function setCss(obj,css){
    48. obj.setAttribute("style",css);
    49. obj.style.cssText = css;
    50. }  
  • 相关阅读:
    Redis的分布式锁
    Redis的雪崩、击穿、穿透
    psr规范
    Mysql的联(复)合索引
    nginx的location配置(二)
    nginx的location规则(一)
    easyswoole中队列的使用
    第三章 文件I/O
    移动语义及拷贝优化
    PHP对接tdzntech.com云平台电子免费券程序
  • 原文地址:https://www.cnblogs.com/bjanzhuo/p/3576101.html
Copyright © 2020-2023  润新知