jQuery: The Write Less, Do More JavaScript Library

Re: Div and Button display as active and open only on certain pages

by Doug Nelson-2 :: Rate this Message:

Reply to Author | View in Thread


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();
});

}

 « Return to Thread: Div and Button display as active and open only on certain pages