jquery - Create vertical scrollbar dynamically if the content exceeds the the container height -
i have main div container contains 2 divs- front, .the first div contains 2 tables named mytable , mytable1 covered each 2 divs named drag , drag1 respectively.the second div ie., contains 1 table fixed.so,what have add vertical scrollbar dynamically 1st div tables ie., mytable , mytable1 if height exceeds height of container ie.,front covering both tables.i have tried doesn't work. please help!!
var ab = $('#mytable').height(); var bc = $('#mytable1').height(); var ca = $('#front').height(); if(ab+bc > ca) { $("#drag").css({"overflow":"auto","overflow-x":"hidden","overflow-y":"auto"}); $("#drag1").css({"overflow":"auto","overflow-x":"hidden","overflow-y":"auto"}); }
below code how table being created-
$(document.createelement('div')).attr('id', 'drag').appendto('#front'); $("#drag").css({"border":"thin solid #ccc","position":"relative","width":"97%"}); $(document.createelement('table')).attr('id', 'mytable').appendto('#drag'); $("#mytable").css({"width": "100%","border-collapse":"collapse"}); $(document.createelement('div')).attr('id', 'drag1').appendto('#front'); $("#drag1").css({"border":"thin solid #ccc","position":"relative","width":"97%"}); $(document.createelement('table')).attr('id', 'mytable1').appendto('#drag1'); $("#mytable1").css({"width": "100%","border-collapse":"collapse"});
Comments
Post a Comment