JQuery更改< object>的数据属性 [英] JQuery changing data attribute of <object>
问题描述
在FF中完美运行(正如您所期望的那样),但出于某些原因,当我这样做时:
Works perfectly in FF (as you'd expect) but for some reason when I do this:
$('#objectname').attr('data', 'newcontent.php')
...绝对IE中没有任何反应。
...absolutely nothing happens in IE.
当我执行
alert($('#objectname').attr('data', 'newcontent.php'))
它显示了新的数据源,但没有改变它......
it shows the new data source but doesn't change it...
有任何想法吗?
推荐答案
我认为 data
是一个有效的HTML属性。你的意思是使用jQuery data()
function?
I don't think data
is a valid HTML attribute. Did you mean to use the jQuery data()
function?
$('#objectname').data('name','value');
2014年9月更新 - 此问答已超过五年现在已经过时了,现在已经不再那么重要了。 data
现在是一个有效的属性。出于历史目的,我将离开原来的答案。
Update for 9/2014 — This question and answer is over five years old now, and isn't really relevant any more. data
is now a valid attribute. I'm leaving my original answer for historical purposes though.
这篇关于JQuery更改< object>的数据属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!