Here is the code that fails:
var newName= "jill"
$("h1").attr('itemprop','name').html(newName);
Here is the microdata:
<body itemscope itemtype="http://schema.org/Blog">
<div style="display:none;">
<h1 itemprop="name">jack</h1>
<img itemprop="image" src="http://somehewhere.com/something.png" />
<p itemprop="description">some text</p>
</div>
I need to change the value of “jack” to “jill”.
I’m changing it for use with G+ since the var value of “jill” (although static in this example) will change since it is dynamic.
Thanks in advance for your help!
You can change the value with jQuery as Adil showed, but that doesn’t solve your issue. Google+ takes a snapshot of the HTML to decide how to create the snippet either before your javascript runs or doesn’t execute the javascript at all.
You’re better off making the page dynamic by using a server-side language.
Maybe with some more explanation about your situation, we can suggest another approach or workaround?