首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

初学者提问,通过js改变上面的属性值

2012-12-20 
菜鸟提问,通过js改变下面的属性值svg width200 height250rect idx x10 y10 width30

菜鸟提问,通过js改变下面的属性值
<svg width="200" height="250">  
  <rect id="x" x="10" y="10" width="30" height="30" stroke="black" fill="transparent" stroke-width="5"/>  
  <rect x="60" y="10" rx="10" ry="10" width="30" height="30" stroke="black" fill="transparent" stroke-width="5"/>  
</svg> 
比如这样一段html,我如何能通过js,去改变这个id为x,的rect的长,宽,高什么的啊
[最优解释]
document.getElementsByTagName("svg")[0].children[0].setAttribute("id", "xxx")
w = document.getElementsByTagName("svg")[0].children[0].getAttribute("width")
[其他解释]

引用:
document.getElementsByTagName("svg")[0].children[0].setAttribute("id", "xxx")
w = document.getElementsByTagName("svg")[0].children[0].getAttribute("width")


同意
[其他解释]
document.getElementsByTagName("svg")[0].children[0].setAttribute("id", "xxx")
w = document.getElementsByTagName("svg")[0].children[0].getAttribute("width")
[其他解释]
引用:
document.getElementsByTagName("svg")[0].children[0].setAttribute("id", "xxx")
w = document.getElementsByTagName("svg")[0].children[0].getAttribute("width")
这个就可以了
[其他解释]
新论坛的样子,不错
[其他解释]
该回复于2012-11-07 17:20:20被管理员删除

热点排行