当前位置: 首页 > news >正文

网页制作 软件深圳百度seo公司

网页制作 软件,深圳百度seo公司,盐城注册公司流程和费用,做私房蛋糕在哪些网站写东西最近,在书写div块时,遇到一个小问题,这个小问题我搞了将近一个小时多才慢慢解决。问题是这样子的,有一个div块,我想让鼠标移上去变成蓝色,移开变成灰色,当鼠标按下去时让他变成深蓝色。于是就单…

最近,在书写div块时,遇到一个小问题,这个小问题我搞了将近一个小时多才慢慢解决。问题是这样子的,有一个div块,我想让鼠标移上去变成蓝色,移开变成灰色,当鼠标按下去时让他变成深蓝色。于是就单纯添加onmouse事件,实验起来发现,笔者鼠标按下去确实变色,但是移开时却又变回来。于是为了此问题写了这篇博文

1、问题起源

div变颜色不如笔者想法,移上去变色,移开变色,按下去变色但不想让按下去再移开变色。

2、问题解决方案

设计onmouse事件,温习下onmouse事件

  • onmousedown 事件会在鼠标被按下时发生
  • onmouseup:事件会在用户鼠标时按键被松开时执行
  • onmousemove:事件会在鼠标移动到指定元素后执行
  • onmouseout:事件会在鼠标移出指定的元素对象时执行
<!DOCTYPE html>
<html><head><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css"integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous"><meta charset="utf-8"><title></title><style>#mTestCases{width:100px;height:100px;background-color: grey;}#mAuto_Test {width:100px;height:100px;margin-top:5px;background-color: grey;}</style></head><body><div id="mTestCases"></div><div id="mAuto_Test"></div><script>var tmp1 = document.getElementById("mTestCases");tmp1.onmousedown = function(){this.style.backgroundColor = "rgb(72,152,246)";this.style.color = "white";this.onmouseout = null;var tp2 = document.getElementById("mAuto_Test");tp2.onmouseout = function(){this.style.backgroundColor='rgb(249,250,255)';this.style.color='rgb(94,104,134)';}tp2.style.backgroundColor = "rgb(249,250,255)";tp2.style.color = "rgb(94,104,134)";}tmp1.onmousemove = function(){this.style.backgroundColor = "rgb(72,152,246)";this.style.color = "white";}var tmp2 = document.getElementById("mAuto_Test");tmp2.onmousedown = function(){this.style.backgroundColor = "rgb(72,152,246)";this.style.color = "white";this.onmouseout = null;var tp2 = document.getElementById("mTestCases");tp2.onmouseout = function(){this.style.backgroundColor='rgb(249,250,255)';this.style.color='rgb(94,104,134)';}tp2.style.backgroundColor = "rgb(249,250,255)";tp2.style.color = "rgb(94,104,134)";}tmp2.onmousemove = function(){this.style.backgroundColor = "rgb(72,152,246)";this.style.color = "white";}</script></body></html>

3、问题测试效果

鼠标移上去
在这里插入图片描述
移开后

在这里插入图片描述

鼠标点击
在这里插入图片描述

http://www.fp688.cn/news/160137.html

相关文章:

  • 自己做的网站给人攻击了怎么办百度搜索一下
  • 做诱导网站网站收录免费咨询
  • 谷哇网站建设怎样创建一个网站
  • 广州网站百度排名推广合肥网站seo整站优化
  • 做网站需要提供哪些信息网络推广销售是做什么的
  • 微信在线客服系统网页seo实战培训视频
  • 上海最新的疫情数据seo教程网
  • 企业管理软件排行榜高端seo服务
  • 手机网站的特效2023全民核酸又开始了
  • 自己做网站怎么优化新app推广方案
  • 做网站备案是个人还是企业好搭建网站教程
  • 中山 网站建设一条龙服务关键词优化难度查询
  • 专门做英雄联盟h漫的外国网站淘宝推广引流方法有哪些
  • 响应式网站是做多大尺寸俄罗斯搜索引擎浏览器官网入口
  • 天津工程建设协会网站今天宣布疫情最新消息
  • 网站制作案例 立邦雷神代刷网站推广
  • thinkphp网站开发实战教程湖南正规seo优化报价
  • 搭建网站赚钱达内教育
  • 深圳网站建设 设计科技有限公司免费的短视频app大全下载
  • 衢州网站制作电话百度
  • 百度网站建设长春疫情最新消息
  • 公司网站设计网络公司厦门网站建设公司哪家好
  • 做网站公司上班违法吗做小程序的公司
  • 怎样做网站导购教程淘宝店铺怎么引流推广
  • 专门做ryona的网站谷歌seo视频教程
  • 郑州大型网站建设价格电商运营怎么做如何从零开始
  • 做网站几个步骤广州网络推广公司有哪些
  • 深圳摇号申请网站导购网站怎么推广
  • 怎么做网站图标企业公司网站建设
  • 免费推广网站在线长春seo排名收费