jQuery attr() fails to set attribute

假装没事ソ 提交于 2019-12-04 23:35:30

Working fine here (with jQuery 1.6.2): http://jsfiddle.net/niklasvh/k3Grd/

Make sure to call it once the DOM is ready:

$(function(){
 $('#trns').attr('transform', 'rotate(60,50,50)');
});

Very strange indeed, this seems to work

$('#trns')[0].setAttribute('transform','rotate(20,50,50)')

Also, if u look at $('#trns').attr('transform'), you are getting an object.. Not enough time to look into that now.

If you're using jquery >= 1.6 try using prop instead of attr.
Hope this helps. Cheers

.attr() works in 3.1.1 like this

.attr({ style: "prop : val; prop : val; prop : val" })

this might be a way around version problems.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!