Get ALL instances of ONE attribute instead of just one
<p>So I am displaying graphs based on selection of checkboxes and have run into a small problem.</p>

<p>I am currently looping through and selecting only the first graph, even when a select-all checkbox is checked - meaning I get however many amounts of the same first graph instead of the ten unique graphs. </p>

<p>As you will see in the code below, the previous line I was using that is commented out:</p>

<pre><code>//var fnInstance=$('#counterTreeviewUL'+idTreeview)[0].children[i].children[0].attributes[1].value;
</code></pre>

<p>Works perfectly in Firefox <strong>ONLY</strong> - it displays all graphs correct etc. but does not work in Chrome/IE due to the way it is attempting to access elements.</p>

<p>I have replaced it with these two lines:</p>

<pre><code>$el = $('#counterTreeviewUL'+idTreeview).first();
var fnInstance = $el.find("input").attr("onclick");
</code></pre>

<p>The two lines I have replaced it with cause everything to function in all three browsers (no errors in IE or Chrome anymore), <strong>however</strong> the only graph that is ever shown is the first one found - if three elements have been selected then 3 versions of the first graph will show instead of the 3 unique ones.</p>

<p><strong>The full code is below, and console.logs of what the elements contain are below that:</strong></p>

<pre><code>for (var i=0;i&lt;$('#counterTreeviewUL'+idTreeview)[0].children.length;i++)
{

 if (!$('#counterTreeviewUL'+idTreeview)[0].children[i].children[0].checked)
 {  
        $('#counterTreeviewUL'+idTreeview)[0].children[i].children[0].checked=true;


//var fnInstance=$('#counterTreeviewUL'+idTreeview)[0].children[i].children[0].attributes[1].value;

        $el = $('#counterTreeviewUL'+idTreeview).first();
        var fnInstance = $el.find("input").attr("onclick");


        fnInstance=fnInstance.substr(15).substr(0,fnInstance.length-2);

        var flagsInstance=fnInstance.split(new RegExp(","));

        var graph = {
                id: seqId,
                entityName: flags[6].substr(1).substr(0, flags[6].length - 2),
                entity: flags[5].substr(1).substr(0, flags[5].length - 2),
                idCounter: flags[4],
                counterName: flags[3].substr(1).substr(0, flags[3].length - 2),
                ivmanager: flags[7].substr(1).substr(0, flags[7].length - 2),
                chart: null,
                pointsToShowX: null,
                borneInf: null,
                unite: "",
                idInstance: flagsInstance[2].substr(1).substr(0, flagsInstance[2].length - 2),
                instanceName: flagsInstance[3].substr(1).substr(0, flagsInstance[3].length - 2),
                listPdsNull: new Array(),
                countInstance: idTreeview + "_" + i,
                countGraph: -1
            };

        seqId++;        
        graphs[graphsLastId]=graph;     
        graphsLastId++;
    }
}
</code></pre>

<p><strong>Console.logs of elements:</strong></p>

<p><img src="http://i.stack.imgur.com/H1zId.png" alt="enter image description here"></p>

<p>Any help would be greatly appeciated as I have spent hours trying to work out (another previous employee's) code..</p>

<p>I basically just need a browser-friendly version of this line - </p>

<pre><code> var fnInstance=$('#counterTreeviewUL'+idTreeview)[0].children[i].children[0].attributes[1].value;
</code></pre>
