turning this code to parend and childe based one

its a code that allows user to scroll on x position using click and hold the problem is that every new galley i make should have another code with new id and new class i hope that i can make a dynamic code that works for everyElement that i have on my page for more description you can visit my website
enter link description here

$("#stuff3").mousedown(function(e){
    e.preventDefault();
    down=true;
    x=e.pageX;
    y=e.pageY;
    top=$(this).scrollTop();
    left=$(this).scrollLeft();
});

$(".news").mousemove(function(e){
    if(down){
        var newX=e.pageX;
        var newY=e.pageY;

        //console.log(y+", "+newY+", "+top+", "+(top+(newY-y)));

        $("#stuff3").scrollTop(top-newY+y);
        $("#stuff3").scrollLeft(left-newX+x);
    }
});