Add an attribute if not already there
<p>How would I add an attribute to an element if that element does not already have that attribute?</p>

<pre><code>if (' this does not have class=selected') {

    $(this).addClass('selected');
}
</code></pre>
