Jquery scroll to wrapped float element

by amindunited

HTML

<div class="parent">
<div class="sib">SIB</div>
<div class="target">TARGET</div>
</div>

CSS

.sib, .target {
    width:150px;
    height:150px;
    border:solid 1px green;
    float:left;
}

JavaScript

$(document).ready(function(){
    console.log($(".target").offset())
});
$('.target').on('click', function(){
    console.log($(".target").offset())
    $('body').scrollTop($(".target").offset().top)
});