$(\'.test\').css(\'background\',\'red\'); Some text
How can I .addClass(\'test\') if #exa
.addClass(\'test\')
#exa
try the following code
$('#example:contains("text")').addClass('test');
Have a look here for examples and explanations of the :contains selector
:contains