Hi Alex,

Often, if you're hiding information on page load, you'll want to have that information available upon some user interaction. Hiding that information with CSS would make the information unavailable to anyone who has JS off but CSS on. Probably not a huge percentage of users, but it's nice to let everyone see the content. Hiding the content with JavaScript follows the principle of Progressive Enhancementâ„¢ . Nice article -- the first in a series -- about that on alistapart.com: http://www.alistapart.com/comments/understandingprogressiveenhancement/

--Karl

____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com




On Oct 8, 2008, at 8:30 AM, Alex Weber wrote:


Just a random question here: why would you hide the element with
jQuery as opposed to using CSS?  (on pageload that is...)

On Oct 7, 5:50 pm, "John D." <[EMAIL PROTECTED]> wrote:
Ok I found the culprit. There was a JavaScript for our Google site
search. Commenting it out solves the problem.

It's a Coldfusion page. I'm not sure why this bit of JavaScript, which
is included at the bottom of  the page is causing the problem.

Shouldn't the paragraph hide before the site search JavaScript is
executed?

Thanks for helping!

John

Brandon Aaron wrote:
Make sure your styles are included before the script tags. Is this happening
in a particular browser?
--
Brandon Aaron

On Tue, Oct 7, 2008 at 1:58 PM, John D. <[EMAIL PROTECTED]> wrote:

Hmm...I'm still having trouble with this.

my showHide script is as follows:

$(document).domready(function() {
   $('body').addClass('jsEnabled');  // let css know js is enabled
   $('p.firstparagraph').hide()
   $('#showh1').click(function(){
  $('p.firstparagraph').show(200);
  });
  $('#hideh1').click(function(){
  $('p.firstparagraph').hide(200);
  });
 });

Including the following:
<script type="text/javascript" src="http://code.jquery.com/
jquery.js <http://code.jquery.com/jquery.js>"></script>
<script type="text/javascript" src="js/jquery.domready.js"></ script>
<script type="text/javascript" src="js/showHide.js"></script>

and added the following CSS rule:

body.jsEnabled p.firstparagraph { display: none; }

Still the firstparagraph is showing then disappearing on page load.
The page validates for both css and html.

Any thoughts?

Thanks!

John

On Oct 7, 10:28 am, Nabha <[EMAIL PROTECTED]> wrote:
Installed the plugin, and it works great! I'm using it just as you
suggested.

For those who find this later, you'll want to "minify" the javascript
file:http://www.digitaloverload.co.uk/jsmin/

And this is code you can copy and paste (has a fixed typo):

$(document).domready(function() {
    $('body').addClass('jsEnabled');

});

Reply via email to