How do i access href attributes of <a> to compare urls as per requriement?
<pre><code>&lt;style&gt;
.aaaa{
background:red;
}
&lt;/style&gt;

&lt;div class="subnav_catg"&gt;
&lt;article id="anything" class="catg_list"&gt;&lt;a class="catg_photo" href="http://www.xyz.com/1"&gt; &lt;img src="http://www.xyz.com/11.jpg"&gt; &lt;/a&gt; &lt;hgroup&gt;
        &lt;h1 class="catg_title"&gt;
            Make it&lt;/h1&gt;
        &lt;/hgroup&gt; &lt;/article&gt;
&lt;article id="anything" class="catg_list"&gt;&lt;a class="catg_photo" href="http://www.xyz.com/2"&gt; &lt;img src="http://www.xyz.com/65.jpg"&gt; &lt;/a&gt; &lt;hgroup&gt;
        &lt;h1 class="catg_title"&gt;
            Chocolate&lt;/h1&gt;
        &lt;/hgroup&gt; &lt;/article&gt;
&lt;article id="anything" class="catg_list"&gt;&lt;a class="catg_photo" href="http://www.xyz.com/3"&gt; &lt;img src="http://www.xyz.com/79.jpg"&gt; &lt;/a&gt; &lt;hgroup&gt;
        &lt;h1 class="catg_title"&gt;
            Divine&lt;/h1&gt;
        &lt;/hgroup&gt; &lt;/article&gt;
&lt;/div&gt;

&lt;script&gt;
var url_string = document.URL;
var mainarticle = document.querySelectorAll('.subnav_catg');
for (var i = 0; i &lt;= mainarticle.length; i++) {
    var current_article = mainarticle[i];
    if (url_string == current_article.firstChild.attributes[href]) {
        var theParagraph = getElementsByClassName('catg_list');
        theParagraph.setAttribute('id', 'aaaa');
    }
}
&lt;/script&gt;
</code></pre>

<p>In above code i am comparing current url with 'a' tag which is in each article if it matches than replace id from 'anything' to 'aaaa'
but i am not getting. so Whats wrong?</p>
