Using index in jquery for div

Index replacing of divs in jQuery when re-sizing window

by stackmanoz

HTML

<div class="container">
<div class="row-fluid">
<div class="span4"><a href="#">Registration</a></div>
<div class="span4"><a href="#">Upload Document</a></div>
<div class="span4"><a href="#">See Profile</a></div>
</div>
<div class="show-all" >Show All</div>
</div>

CSS

.container{
   
 
}
.show-all
{
    height: auto;
    width: 100px;
    background: #98bf26;
    padding: 4px;
    text-align: center;
    color: white;
    font-family:Calibri;
    font-weight:bold;
    margin:.7em;
    cursor:pointer;
    margin:0 auto;
    
}
.show-all:hover
{
    background:#c10000;
}

.row-fluid [class*="span4"]
{
    display: inline-block;
    width: 32%;
    height: 50px;
    text-align: center;
    background: #98bf26;
    position: relative;
    min-width: 200px;
    margin: .3em;
 
}
.row-fluid [class*="span4"]:hover
{
    background: #c10000;
}
.row-fluid [class*="span4"] a
{
    font-size: 22px;
    color: White;
    font-family: Calibri;
    line-height: 50px;
    text-decoration: none;
}

JavaScript

$(function () {
        var $index = $('.row-fluid .span4:nth-child(3)').index()+1;
    alert($index);
        $('.container .row-fluid .span4 ').click(function () {
            $(this).show().siblings().fadeOut();
            var y= $(this).index();
            var z= $(this).index(y)+3;
             $(this).css('margin',y);
        
            alert(z);
        });
        $('.show-all').click(function () {
            $('.span4').fadeIn();
        });
    });