1

Here is the code that shows success in console log but fails when tested with Google's Structured Data Testing Tool or with G+ share button. The original values remain. In this case "jack" never updates to "jill".

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>

As you can see, just trying to change the value of "jack" to "jill".

unor
  • 92,415
  • 26
  • 211
  • 360
user1452893
  • 838
  • 1
  • 11
  • 29

3 Answers3

1

The html() method cannot be used on the itemprop attribute. You need to apply it to just the h1 tag instead:

$("h1[itemprop=name]").html(newName);

or since newName is simple text:

$("h1[itemprop=name]").text(newName);
mongo505
  • 63
  • 5
0

That's because GoogleBot (and all the others, for that matter) doesn't execute (all) javascript. You won't have any success setting or changing microdata properties by any client side script.

tosc
  • 759
  • 4
  • 16
  • Is this still the case? Ref. http://googlewebmastercentral.blogspot.com/2014/05/understanding-web-pages-better.html – Mark Boulder Sep 30 '15 at 17:26
  • Short answer: yes, Longer answer, see: https://stackoverflow.com/questions/32872318/changing-schema-org-microdata-with-jquery/32872610#32872610 – tosc Sep 30 '15 at 17:49
0

Changing microdata values was no sense, since as dwtm.ts said, bots don't execute javascript and parse only source code downloaded directly when they get the pages. You should use "fetch as googlebot" test tool from GWT to check how search bots "read" your page.

xserna
  • 46
  • 4