Well, this is a straight answer:
pass input text into getCapitalize
below javascript function and it will return you expected output-
var text = $(".capitalize").text();
var formattedText = getCapitalize(text); // use of function
$(".capitalize").text(formattedText); // assign formatted text the container
function getCapitalize(text){ //formatter function
var textArray = text.split(" ");
for(i= 0; i<textArray.length; i++){
textArray[i] = textArray[i][0].toUpperCase() + textArray[i].substr(1).toLowerCase();
}
return textArray.join(" ");
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p class="capitalize">HELLO I AM HERE.</p>
Hoping this will help you:)