$('p').on('click', function () {
$(this).attr('data-before','bar');
});p:before {
content: attr(data-before);
color: red;
cursor: pointer;
}<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>