onclick on link display only div, make other body balck or shaded
I have a page which has anchor tag clicking on which ma div tag toggles. I 开发者_StackOverflowwant to make whole body of page black or shaded except that Div tag.
Well then you need to set body's background color first and then your div's background. So make function toggle
which would check for presence of class in both elements and then ether add or remove class attribute (for both elements) with $('#mydiv').addClass('foo')
or $('#mydiv').removeClass('foo')
. Then you can use CSS to declare background colors for body and then div: add class - color in, remove class - color out
It sounds like you really want a "Modal Dialog" type of display. There are a number of JQuery and other methods to do this.
Here is a good one that I've used before, Simple Modal
精彩评论