<style type="text/css">
body {
/* Some other stuff here */
background-image: url(http://localhost/images/bg.jpg);
background-repeat: repeat-x;
}
</style>
<body>
<!-- Some other stuff here -->
</body>
The background was the element I wanted to hide. I ended up with something like this:
<style type="text/css">
body {
/* Some other stuff here */
background-image: url(http://localhost/images/bg.jpg);
background-repeat: repeat-x;
}
</style>
<script type="text/javascript" language="javascript" src="jquery.js"></script>
<body>
<!-- Some other stuff here -->
<a id="mini" href="#" OnClick="
if ( $('#mini').text() == '[-]' ) { $('#mini').text('[+]') } else { $('#mini').text('[-]'); }
if ($('body').css('background-image') == 'url(http://localhost/images/bg.jpg)')
{ $('body').css('background-image','url()'); } else
{ $('body').css('background-image','url(http://localhost/images/bg.jpg)'); }
return false;">[-]</a>
<!-- and here -->
</body>
This adds a small [-] link that, when clicked, clears the background and changes to a [+]. Clicking again switches back.
css classes? (Score:1)
Wouldn't switching the body's css class also work and make it all more maintainable? :)
Ordinary morality is for ordinary people. -- Aleister Crowley
Re: (Score:1)
Re: (Score:1)
It’s not TMTOWTDI… it’s a matter of, as Larry likes to say, baby talk. What you did is a way to do it, but really it’s not a very good way. Switching the
bodyclass is one thing you should really do; the other is unobtrusive scripting [wikipedia.org]. Another thing is that you want to hide these links from people who don’t have Javascript in the first place.Consider:
Re: (Score:1)
Err,
s/jQuery/\$/.Re: (Score:1)
I can still remember those ugly times of NN4, where we still had to assume people who don't have JS on, might also have CSS off. The days really got better in this regard.
Ordinary morality is for ordinary people. -- Aleister Crowley