How to select div contains parent div attr?
<p>I try to select <code>img</code> in <code>.sub rel='0'</code> and trigger click, looks like <code>$('.sub[rel=0] img').trigger('click')</code> , but it does't work. <br>What is wrong with this selector code <code>$('.sub[rel=0] img')</code></p>

<p>Thanks!</p>

<pre><code>&lt;div class="sub" rel="0"&gt;
    &lt;img&gt;
&lt;/div&gt;
&lt;div class="sub" rel="1"&gt;
    &lt;img&gt;
&lt;/div&gt;
</code></pre>

<p><strong>Update</strong></p>

<pre><code>function geturlvars(){
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&amp;');
    for(var i = 0; i &lt; hashes.length; i++){
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
return vars;
};

realid = geturlvars()["id"]
function checkstate(){
    if(realid){
        $('.sub[rel=realid] img').trigger('click');
    }
    $('.sub[rel=realid] img').click(function(){
        console.log('hi');
    });
};
checkstate();
</code></pre>
