ScrollTop inside a div with external links
ScrollTop inside a div with external links - you have no idea how happy I was to make this work - Andrew Pougher
HTML
<div class = "click">hotel-chamonix</div>
<div class = "click">biartisc</div>
<div class = "click">Norwich</div>
<div class = "click">Mundelein</div>
<hr>
<div class='box' id="sidebarlink">
<div class='content'>
<div id="example" style="width:100px; height:100px;margin:2px; background-color:#ff0000; ">A</div>
<div id="example" style="width:100px; height:100px;margin:2px; background-color:#ff0000; ">A</div>
<div id="example" style="width:100px; height:100px;margin:2px; background-color:#ff0000; ">A</div>
<div id="example" style="width:100px; height:100px;margin:2px; background-color:#ff0000; ">A</div>
<div id="example" style="width:100px; height:100px;margin:2px; background-color:#ff0000; ">A</div>
<div id="example" style="width:100px; height:100px;margin:2px; background-color:#ff0000; ">t</div>
<div id="example" style="width:100px; height:100px;margin:2px; background-color:#ff0000; ">Norwich</div>
<div id="example" style="width:100px; height:100px;margin:2px; background-color:#ff0000; ">A</div>
<div id="example" style="width:100px; height:100px;margin:2px; background-color:#ff0000; ">A</div>
<div id="example" style="width:100px; height:100px;margin:2px; background-color:#ff0000; ">A</div>
<div id="example" style="width:100px; height:100px;margin:2px; background-color:#ff0000; ">2</div>
<div id="example" style="width:100px; height:100px;margin:2px; background-color:#ff0000; ">3</div>
<div id="example" style="width:100px; height:100px;margin:2px; background-color:#ff0000; ">hotel-chamonix</div>
<div id="example" style="width:100px; height:100px;margin:2px; background-color:#ff0000; ">biartisc </div>
<div id="example" style="width:100px; height:100px;margin:2px; background-color:#ff0000; ">A</div>
<div id="example" style="width:100px; height:100px;margin:2px; background-color:#ff0000; ">A</div>
<div id="example" style="width:100px; height:100px;margin:2px; background-color:#ff0000;...
CSS
.box {height:300px;overflow:scroll;border:3px solid #eee}
.content{position:relative; top:5px}
JavaScript
var c= 'hotel-chamonix'
$divpoint = $("div:contains('"+c+"')");
$(".click").click(function () {
var $where = $(this).text();
var $parentDiv = $('#sidebarlink');
var $innerListItem = $('.content');
$parentDiv.animate({
scrollTop: ( $('.content div:contains("'+$where+'")').offset().top
- $('#sidebarlink').height() + $('.content div:contains("'+$where+'")').height())}, 1000 );
});