Works perfectly in FF (as you'd expect) but for some reason when I do this:
$('#objectname').attr('data', 'newcontent.php')
...absolutely nothing happens in IE.
When I do an
alert($('#objectname').attr('data', 'newcontent.php'))
it shows the new data source but doesn't change it...
Any ideas please?
I don't think data
is a valid HTML attribute. Did you mean to use the jQuery data()
function?
$('#objectname').data('name','value');
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.
We had the same problem. Our solution was to re-set the innerHtml of the parent node. With this (ugly) hack IE picks up the changed data attribute and renders accordingly.
html = val.parentNode.innerHTML;
val.parentNode.innerHTML = html;