Question: I have a bunch of DIV's that all have the same class and style except for 1.

```
    <div id="0" class="divpage" style="display:none"></div>
    <div id="1" class="divpage" style="display:none"></div>
    <div id="2" class="divpage" style="display:none"></div>
    <div id="3" class="divpage" style="display:none"></div>
    <div id="4" class="divpage" style="display:block"></div>
    <div id="5" class="divpage" style="display:none"></div>
    <div id="6" class="divpage" style="display:none"></div>

```

I need to find out the id of the div that is 'display:block'. I used the following code but it only returns the first div's id.

```
var num = $(".divpage").attr("id");

```

How do I modify this to find the correct id?

Thanks in advance.

Answer: 
using `:visible` will find the div that is visible

You should not use numbers as id, i think its only valid in html5

```
var num = $('.divpage:visible').attr('id');

```
Like this - 

```
var theID = $('.divpage[style="display:block"]').attr('id');

```