Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
HTML
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
function CreateComponents() {
	for(var i=0;i<10;i++)
	{
		$("#TreeView").append("<ul id='Comp" + i + "'><input type='checkbox' id='Component" + i + "' name='Component" +i + "' onchange='GetMemos(\"Comp" + i + "\",\"" + i + "\");' /><a>" + i + "</a></ul>");    
	}
}

function GetMemos(Tagid, data) {    
    if ($("#" + Tagid + " li").length == 0) {
        $("#" + Tagid).addClass('parent');
        for(var i=11;i<20;i++){            
            $("#" + Tagid + "").append("<li style='padding-removed20px'><input type='checkbox' id='Memo" + i + "' name='Memo" + i + "' /><a>" + i + "</a></li>")
		}
    }
}


</script>
</head>
<body>
<div id="TreeView" style="width:50%;border:2px solid;height:75%;overflow:hidden;"></div>
<input type="button" value="Create Components" onclick="CreateComponents();" />
</body>
</html>


When i click the Create Component button, i will add some ul and on checkbox of each ul i will add some li.

What i want to do is to make the div size permanent with width 50 % and height 50%.

Can anyone please help me

Thanks in advance
Posted
Updated 17-Jan-15 22:29pm
v2

1 solution

To make a div fixed-size and its content scrollable you have to set it's overflow (CSS) property to scroll...
See his code sample: http://jsfiddle.net/Lrt64s71/1/[^]
Notice that in web page the default height is infinite, so it has no meaning to set to 50%, but using some real value...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900