js点击按钮更改html页面的图片(两个来回换)
2017-12-08 10:05
405 查看
<!DOCTYPE html> <html> <body> <img id="image" src="111.png" onmousedown="secound(this)" onmouseup="first(this)"> <button onclick="change()">点击换图片</button> <script> function change() { var x = document.getElementById("image").getAttribute("src"); if (x=="111.png"){ document.getElementById("image").src="222.png"; } else{ document.getElementById("image").src="111.png"; } //alert(x); } function secound(obj){ obj.src="222.png"; console.log(obj.getAttribute("src")); } function first(obj){ obj.src="111.png"; console.log(obj.getAttribute("src")); } </script> </body> </html>
这里是我们的图片
页面效果: http://shuaishuaicloud.cn/4444.mp4
(我的腾讯云主机) 可能到2018 6 就不能用了那时我已毕业
点击打开链接
相关文章推荐
- 在HTML页面上点击按钮按钮携带参数flag,触发一个JS函数,经过判断是否flag==1,分别跳到两个指定的方法(或者页面)
- HTML+JS之点击按钮滚动到页面指定位置
- html js点击按钮滚动跳转定位到页面指定位置(DIV)的方法代码
- dropzone.js点击删除图片按钮后只执行action不跳转到新的jsp页面,也不刷新本页面
- html基础 提交按钮 数据重置按钮 带图片的按钮 普通按钮,点击关闭当前页面
- html基础 提交按钮 数据重置按钮 带图片的按钮 普通按钮,点击关闭当前页面
- js---点击radio按钮实现图片轮换(two methds)
- HTML+js+css实现点击图片弹出上传文件窗口的两种思路
- js 鼠标点击一个按钮显示div的浮动框,点击页面其他任何地方后,隐藏浮动框
- javaScript--对话框(在a.html页面点击按钮跳转到b.html页面,在b页面输入数据后,数据传回a页面)
- html不刷新页面更新js和图片
- js 按钮实现跳转页面 jsp html
- PHP——0128练习相关2——js点击button按钮跳转到另一个新页面
- atitit.GUI图片非规则按钮跟动态图片切换的实现模式总结java .net c# c++ web html js
- 用 JS 点击左右按钮 使图片切换
- js点击button按钮跳转到页面代码
- js获取html页面代码中图片地址的实现代码
- 页面html图片按钮多种写法
- 用户点击获取验证码之后我们会发送一条信息到用户手机,然后就会出现一个倒计时按钮,很像支付宝手机付款效果了,下面我给大家分享两个js效果
- js点击button按钮跳转到页面代码