JQuery change data attribute <object>

Works well in FF (as you would expect), but for some reason when I do this:

$('#objectname').attr('data', 'newcontent.php')

      

... absolutely nothing happens in IE.

When i do

alert($('#objectname').attr('data', 'newcontent.php')) 

      

it shows the new datasource but doesn't change it ...

Any ideas please?

0


a source to share


2 answers


I don't think this data

is a valid HTML attribute. Did you mean jQuery function data()

?

$('#objectname').data('name','value');

      



9/2014 Update - This question and answer is over five years old and is no longer relevant. data

is now a valid attribute. I am leaving my original answer for historical purposes.

0


a source


We had the same problem. Our solution was to re-install the innerHtml of the parent node. With this (ugly) hack, IE picks up the modified data attribute and renders accordingly.



html = val.parentNode.innerHTML;
val.parentNode.innerHTML = html;

      

0


a source







All Articles