jquery属性setter创建了新属性而不是替换

时间:2013-10-17 12:21:35

标签: javascript jquery html vml

请找到以下VML元素

<v:shape id=container_vml_CrosshairVertical style="HEIGHT: 1000px; POSITION: absolute; LEFT: 0px; TOP: 0px; VISIBILITY: visible; WIDTH: 1000px" coordsize = "1000,1000" fillcolor = "white" strokecolor = "black" strokeweight = "1pt" path = " m513,58 l513,374 e"></v:shape>

我将通过path =“M 426 58 L 426 374”更改路径属性值 当我使用以下代码来设置属性

var val="M 426 58 L 426 374"
 $element.attr('path', val);

它再次在该元素中创建新属性。执行后请参考下面的代码。

<v:shape id=container_vml_CrosshairVertical style="HEIGHT: 1000px; POSITION: absolute; LEFT: 0px; TOP: 0px; VISIBILITY: visible; WIDTH: 1000px" path="M 426 58 L 426 374" coordsize = "1000,1000" fillcolor = "white" strokecolor = "black" strokeweight = "1pt" path = " m513,58 l513,374 e"></v:shape> 

我无法得到它再次创建新属性的确切原因?

谢谢,

希瓦

0 个答案:

没有答案