-1
<h4 class="nobottommargin text-center keywords-data ng-scope">Keywords</h4>

What I want to do is add the item property keywords and assign a value to it for the above tag.

$('.keywords-data').attr('itemprop','alternateName');

With the above step,

<h4 class="nobottommargin text-center keywords-data ng-scope" itemprop="alternateName">Keywords</h4>

Now I want to add the value to alternateName, e.g.:

alternateName = 't1,t2';

Could you please provide me with suggestions on how to do this?

var keywordsData = 't1,t2';
$('.keywords-data').attr('itemprop','alternateName');
$('.keywords-data').attr('itemprop',keywordsData);
unor
  • 92,415
  • 26
  • 211
  • 360
nambu
  • 1
  • 2

1 Answers1

0

your code works fine. If you mean to change the value you can use

JS Fiddle

$("[data-ref=alternateName]").html("test")