`

document.getElementById("modifly_page").src

js 
阅读更多
document.getElementById("modifly_page").src = "";

释义:设置ID为modifly_page的html标签的src属性""里面为值



例子: 动态改变图片
<html>
	<head>
		<title>Src Test!</title>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<script type="text/javascript">
			function bImg(){
				var src = document.getElementById("imgbutton").src;
				
				var index = document.getElementById("imgbutton").src.lastIndexOf("/");
				
				var fileName = src.substr(index + 1)
				
				fileName == "psbe.jpg" ? (document.getElementById("imgbutton").src="psbed.jpg") : (document.getElementById("imgbutton").src="psbe.jpg")
			}
		</script>
	</head>

	<body>
		<img id="imgbutton" src="psbe.jpg" onClick="bImg(imgbutton)" />
	</body>
</html>


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics