So it sounds like you'd want to put a class like "hasOverlay" on the homepage body.
<body class="hasOverlay"> Then, create the function that makes your overlay appear. This function needs to be standalone, don't attach it to an event just yet because we'll need to access it two different ways. So your JS code would look (structurally, at least) like this. function showOverlay(){ $('#overlay').fadeIn(); } $(document).ready(){ if ($("body").hasClass("hasOverlay")) showOverlay(); $("#myButton").click(function(){ showOverlay(); }); }