Samuz Posted June 19, 2012 Share Posted June 19, 2012 How do I keep this type of code DRY.. var test = $(window).height(); $('#selector').css('height', test); $(window).resize(function() { $('#selector').css('height', test); }); It would of been a good idea to just set a static css height, but I want it to appear a certain way regardless of the amount of pixels a user has going down the vertical axis. This is just an example, but on one of my projects i've found that i'm repeating myself a lot in scenarios such as the above. Anyone got any good idea? Quote Link to comment Share on other sites More sharing options...
Jessica Posted June 19, 2012 Share Posted June 19, 2012 function windowResize(){ var test = $(window).height(); $('#selector').css('height', test); } $(window).resize('windowResize'); windowResize(); Quote Link to comment Share on other sites More sharing options...
Samuz Posted June 19, 2012 Author Share Posted June 19, 2012 function windowResize(){ var test = $(window).height(); $('#selector').css('height', test); } $(window).resize('windowResize'); windowResize(); Yeah.. Is it weird I completely forgot about JS functions? Thanks anyhow! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.