[jQuery] 403 error in Firefox fixed, but not sure why it worked
I added the following to one of my files to hide and show a group of
thumbnails and it gave me a 403 error in Firefox only:
$(document).ready(function(){
$('div.more').hide();
$('br.clearbothMore').hide();
$('h2.contract').hide();
$('h2.expand').click(function()
{
$('div.more').toggle('crawl');
$('br.clearbothMore').toggle('crawl');
$('h2.expand').hide();
$('h2.contract').show();
return false;
});
$('h2.contract').click(function()
{
$('div.more').toggle('crawl');
$('br.clearbothMore').toggle('crawl');
$('h2.expand').show();
$('h2.contract').hide();
return false;
});
});
I modified it to this and the 403 error disappeared:
$(document).ready(function(){
$('div.more').hide();
$('br.clearbothMore').hide();
$('h2.contract').hide();});
//this $(document.ready is new
$(document).ready(function(){
$('h2.expand').click(function()
{
$('div.more').toggle('crawl');
$('br.clearbothMore').toggle('crawl');
$('h2.expand').hide();
$('h2.contract').show();
return false;
});
$('h2.contract').click(function()
{
$('div.more').toggle('crawl');
$('br.clearbothMore').toggle('crawl');
$('h2.expand').show();
$('h2.contract').hide();
return false;
});
});
I'm just wondering why adding the extra $(document).ready made it
work? I would like to understand it, so I can avoid any future
problems.
Thanks!