jquery - replacing <a> button in defined circumstances
<p>i have created list of elements. if one element is highlighted (using buttons 'prev' and 'next'), it gets 'active' class. if 'add element' button has been pressed, element gets class 'selected'. but if an active element is selected too, i want to replace 'add button' with 'remove button' - which removes class 'selected' from active element.</p>

<p>here's some code:</p>

<pre><code> if ( $('.active').hasClass('selected') ) {
        $('.add').replaceWith('&lt;a href="#" class="add"&gt;Usuń zdjęcie&lt;/a&gt;');
     $('.add').click(function() {
      $('.active').removeClass('selected');
      return false;
     });
    }
    else {
     $('.add').click(function() {
      $('.active').addClass('selected');
      return false;
     });
    }
</code></pre>

<p>it doesn't work (nothing changes). what's wrong? :|</p>
