Finding number of elements on a page

Hi,
I have a number of elements on a page, which I want to remove. The number changes depending on the number of the results,

ie. div Id like result1, result2, result3 etc.

Is there a way for me to find out the number of items called resultX or is there a way for me to search through all ID’s like result ?

Thanks in advance.

cool, thanks for your help.

pure javascript:


<script type="text/javascript">
    window.onload = function(){
        var divs=document.getElementsByTagName('div')
        for (var i=0;i<divs.length;i++){
            alert(divs[i].id);
        }
    }
</script>

html


<div id="test1"></div>
<div id="test2"></div>
<div id="test3"></div>
<div id="test4"></div>
<div id="test5"></div>
<div id="test6"></div>
<div id="test7"></div>

And jQuery:


<script type="text/javascript">
    $(document).ready(function(){
        $('#hideDivs').click(function(){
            $('.hideMe').hide();
        });
    });
</script>

html


<div id="test1">one</div>
<div id="test2" class="hideMe">two</div>
<div id="test3">three</div>
<div id="test4">four</div>
<div id="test5" class="hideMe">five</div>
<div id="test6">six</div>
<div id="test7">seven</div>

<a href="#" id="hideDivs">Hide Divs</a>