首页 > 编程语言 > 详细

每天一个JavaScript实例-SVG中的javaScript展示

时间:2014-11-03 17:49:40      阅读:202      评论:0      收藏:0      [点我收藏+]
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg width="100%" height="100%" version="1.1"
xmlns="http://www.w3.org/2000/svg">


<script type="text/javascript">
<![CDATA[
	window.onload = function(){
		var square = document.getElementById("square");

		square.onclick = function(){
			
			var color = this.getAttribute("fill");
			console.log(color);
			if(color =="#f00"){
				this.setAttribute("fill","#00f");
			}else{
				this.setAttribute("fill","#f00");
			}
		}
	}
	]]>
</script>


<rect id= "square" x="10" y="10" width="400" height="400"
style="stroke:pink;stroke-width:5;
fill-opacity:0.1;stroke-opacity:0.9" fill="#00f"/>

</svg>

每天一个JavaScript实例-SVG中的javaScript展示

原文:http://blog.csdn.net/waiting7436/article/details/40743063

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!