hide/show a div in wordpress

Detecting index.php specifically may not be the best option because this template file is used in many cases in WordPress. Eventually, all pages will fall back to using index.php if no other template file is associated with this page.

So instead of targeting index.php, get familiar with template hierarchy and try to use conditional tags, whenever possible.

For example, if you want to display the banner only on archive pages you could do something like:

<?php if ( is_archive() ) : ?>
    <div id="banner">
        <!-- Banner content goes here. -->
    </div>
<?php endif; ?>

Similarly, you can combine conditional tags:

<?php if ( is_front_page() && is_home() ) : ?>
    <div id="banner">
        <!-- Banner content goes here. -->
    </div>
<?php endif; ?>

This way your code will be future-proof and compliant with WordPress Coding Standards.