 <pre><code>//global flag to check condition var flag = true; $('#yourelement').click(function(){ if(flag == true){ flag = false; $('#yourotherelement').attr('rel', newValue); }else{ flag = true; $('#yourotherelement').attr('rel', oldValue); } }); </code></pre>