How to find width of all images and apply them to their parent containers

How to find width of all images and apply them to their parent containers

Here is what I do but it does not seem to work.

I use window.varName because I need to reuse them in another functions.

$("#rollovers li img").each(function(){
                        window.imgWidth = $(this).width();                      
                        $("#rollovers li").css("width" , imgWidth );
});