First of all, if you want to select all h1 elements, the selector must be "h1". If you use "h1.color", you are trying to find the h1 element with the css class "color", which you do not have.
color div, jQuerys addClass-method.
, , , jQuery ready, , dom , :
<h1 data-class="blue">Blue</h1>
<h1 data-class="green">Green</h1>
<div class="color">I'm changing colour here.</div>
<script>
$(function() {
$('h1').on('click', function() {
$(".color").addClass($(this).data("class"));
});
});
</script>