detect attribute of variable - jquery
<p>I am working on a script and not sure why this isn't working</p>

<pre><code>function moveIn($selector) {
if( $( $selector[left] ) != null ){
    $direction = 'left';
}else{
    $direction = 'right';
}
</code></pre>

<p>This is does work:</p>

<pre><code>if( $( '#hello[left]' ) != null ){
</code></pre>

<p>This is essentially what I am trying to get spit out. It seems the brackets are causing the problem. How else would this be written? Tips for future coding?
Thanks</p>

<p>Entire function:</p>

<pre><code>function moveIn($selector) {
if( $( $selector + '[left]' ) != null ){
    $direction = 'left';
}else{
    $direction = 'right';
}
var animation = {};
    animation[$direction] = 0;
$($selector).animate(animation, 1500);
}
</code></pre>
