hajjo 0 Junior Poster
function moveScroll(){
	try
	{

		var $j = jQuery.noConflict();
                 var scroll = $j("#applicationBody").scrollTop();
	var anchor_top = $j("#searchResults").offset().top;
    var anchor_bottom = $j("#bottom_anchor").offset().top;
    alert(anchor_bottom);
    if (scroll>anchor_top && scroll<anchor_bottom) {
    clone_table = $j("#clone");

    if(clone_table.length == 0){
    	
        clone_table = $j("#searchResults").clone();
        clone_table.attr('id', 'clone');
        clone_table.css({position:'fixed',
                 'pointer-events': 'none',
                 top:0});
    	
        clone_table.width($j("#searchResults").width());
        $j("#searchResultsList").append(clone_table);
        $j("#clone").css({visibility:'hidden'});
        $j("#clone thead").css({visibility:'visible'});
    }
    } else {
    	
    	$j("#clone").remove();
    }
	}
	catch(err){
		
	}
}

the code above doesnt work to freeze a header of table when scrolling in a div.however the following works when the scrollbar is in window.

function moveScroll(){
    var scroll = $j(window).scrollTop();


    var anchor_top = $j("#maintable").offset().top;
	//alert($(window).scrollTop());
	//alert($("#maintable").offset().top);
    var anchor_bottom = $j("#bottom_anchor").offset().top;
	alert( anchor_bottom);
	//alert($(window).scrollTop());
	//alert($("#maintable").offset().top);
	//alert(anchor_bottom);
    if (scroll>anchor_top && scroll<anchor_bottom) {
    clone_table = $j("#clone");
    if(clone_table.length == 0){
        clone_table = $j("#maintable").clone();
        clone_table.attr('id', 'clone');
        clone_table.css({position:'fixed',
                 'pointer-events': 'none',
                 top:0});
        clone_table.width($j("#maintable").width());
        $j("#table-container").append(clone_table);
        $j("#clone").css({visibility:'hidden'});
        $j("#clone thead").css({visibility:'visible'});
    }
    } else {
    $j("#clone").remove();
    }
}
var $j = jQuery.noConflict();

anyone with a help?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.