strange problem - maybe I'm missing something.
My code:
HTML
<div id="container">
<span data-foo="initial content">Blabla</span>
</div>
jQuery
console.log($("span").data("foo")); //initial content
console.log($("#container").html()); //<span data-foo="initial content">Blabla</span>
$("span").data("foo", "new content");
console.log($("span").data("foo")); //new content
console.log($("#container").html()); //<span data-foo="initial content">Blabla</span> <----- ?!?!?!?!
The very last line shows the unexpected behavior. The modification done previously by .data("foo", "new content")
does not reflect when reading the content via .html()
Fiddle: http://jsfiddle.net/sSZjh/