Q:

Target and convert html text into a class for a parent element

I'm new to jQuery. I have been struggling to figure out a way to take the contents of some h4 tags within a set of divs that have the class of "post" and use their text to add/create an additional class for their parent "post" divs.
I want to add an additional class to the parent "post" div from the contents of that div's h4.tag. I've been able to use the text() function to add classes to the parent divs but the problem is I'm adding every h4 's content as a class to every parent div of "post."
Here's my code:         
var texth4 = $('h4.tag').text();

$(".post").each(function() {
    $(this).addClass(texth4);
});

If someone has some guidance I would sincerely appreciate it.

A:

If I understand correctly, you'd want this:
$('.post').each(function() {
    var texth4 = $(this).find('h4').text();
    $(this).addClass(texth4);
});

The difference in what you had and this is that the variable is set to the text value of the H4 element inside that particular instance of .post.
This assumes an HTML structure like this:
<div class="post">
    <h4>Heading Text</h4>
    ...
</div>

And would result in this:
<div class="post Heading Text">
    <h4>Heading Text</h4>
    ...
</div>

Demo

