Assigning an element an id when document is loaded so it can perform a different function when clicked?
<p>I'm trying to manipulate an <code>id</code> to use the same button to do more then 2 actions.</p>

<p>its something like:</p>

<pre><code>var id;
if(something == 2){
   id = "id";
}else{
   id = "id2";
}

$(".myClass").attr("id", id);
</code></pre>

<p>but, its not good, because if i try to use the <code>id</code> that i set, won't work, maybe because the document was already loaded with no <code>id</code> in the button.</p>

<p>dont think this need a example, <a href="http://jsfiddle.net/SWZMd/15/" rel="nofollow">but i made it</a>.</p>

<p>have another way to do this ?</p>
