I am trying to inverse scroll two select controls. When I scroll down the first select the other one should scroll up. This is what I am currently doing
//scroll first list if second list is scrolled
$("#secondList").on("scroll", function(){
//alert("focused");
$("#firstList").scrollTop($(this).scrollTop());
});
//scroll second list if first list is scrolled
$("#firstList").on("scroll", function(){
$("#secondList").scrollTop($(this).scrollTop());
});
to start the second select box from bottom I am doing this
$("div #secondList").animate({ scrollTop: $("#2").height() }, "slow");
but it starts both selects from bottom. And my html is
<div class="container" style="margin-top: 50px;">
<div id="1">
<select name="color" id="firstList" size="3" class="form-control" ></select>
</div>
<div id="2">
<select name="hex" size="3" id="secondList" class="form-control" style="margin-top: 50px;"></select>
</div>
</div>
NOTE I am dynamically adding the options
$.getJSON("ColorNameMap.json", function(data){
for (var i = 0, len = data.length; i < len; i++) {
var color = data[i].color;
var value = data[i].value;
$("#firstList").append('<option value="'+value+'">'+color+'</option>');
$("#secondList").append('<option value="'+color+'">'+value+'</option>');
}
});
I can see the answers here but I want inverse scrolling. Please help me to proceed in right direction.