JavaScript: How to execute an if/else statement in an onclick attribute?
<p>I'm getting syntax errors while trying to add an if/else statement the onclick attribute. What is the syntax for this?</p>

<pre><code>&lt;div onclick="var element = $('#selector'); if (element.val() == 'something') { alert('hello'); } else { alert('goodbye'); } "&gt;
    Click here 
    &lt;input type="hidden" id="selector" value="something" /&gt;
&lt;/div&gt;
</code></pre>

<p>...and yes, I must have this javascript in the onclick attribute (can't move this to a function).</p>
