javascript help

smoochy boys on tour

Far

tsniffer
Staff member
Developer
May 19, 2003
20,184
30
2,788
540
ive got this code in on my site
PHP:
$(document).ready(function(){
 
	$("a.switch_thumb").toggle(function(){
	  $(this).addClass("swap"); 
	  $("ul.display").fadeOut("fast", function() {
	  	$(this).fadeIn("fast").addClass("thumb_view"); 
		 });
	  }, function () {
      $(this).removeClass("swap");
	  $("ul.display").fadeOut("fast", function() {
	  	$(this).fadeIn("fast").removeClass("thumb_view");
		});
	}); 

});
its basically for switch a menu between 2 views 'thumb_view' and 'display'

it works fine, but whenever i start the page, it always starts on 'display'

how do i change this code so 'thumb_view' is the first one to show?

everything iv tried seems to break it.

if you need any more details about the code, such as the css properties, let me know.
 

Primal

LOMCN VIP
VIP
Jun 28, 2004
1,756
102
259
ive got this code in on my site
PHP:
$(document).ready(function(){
 
	$("a.switch_thumb").toggle(function(){
	  $(this).addClass("swap"); 
	  $("ul.display").fadeOut("fast", function() {
	  	$(this).fadeIn("fast").addClass("thumb_view"); 
		 });
	  }, function () {
      $(this).removeClass("swap");
	  $("ul.display").fadeOut("fast", function() {
	  	$(this).fadeIn("fast").removeClass("thumb_view");
		});
	}); 

});
its basically for switch a menu between 2 views 'thumb_view' and 'display'

it works fine, but whenever i start the page, it always starts on 'display'

how do i change this code so 'thumb_view' is the first one to show?

everything iv tried seems to break it.

if you need any more details about the code, such as the css properties, let me know.

u tried switching it round?


PHP:
$(document).ready(function(){
$("a.switch_thumb").toggle(function(){
$(this).removeClass("swap");
	  $("ul.display").fadeOut("fast", function() {
	  	$(this).fadeIn("fast").removeClass("thumb_view");
		});
}, function () {
	  $(this).addClass("swap"); 
	  $("ul.display").fadeOut("fast", function() {
	  	$(this).fadeIn("fast").addClass("thumb_view"); 
		 });
	}); 

});


somet like that


edit: changed a bit, shud have been at the top
 
Last edited:

Far

tsniffer
Staff member
Developer
May 19, 2003
20,184
30
2,788
540
nah that doesnt work m8. jus makes me have to click the switch button twice before it changes. i tried that :/
 

Primal

LOMCN VIP
VIP
Jun 28, 2004
1,756
102
259
nah that doesnt work m8. jus makes me have to click the switch button twice before it changes. i tried that :/

try this then

PHP:
$(document).ready(function(){ 
  
    $("a.switch_thumb").toggle(function(){ 
      $(this).addClass("swap");  
      $("ul.display").fadeOut("fast", function() { 
          $(this).fadeIn("fast").removeClass("thumb_view"); 
         }); 
      }, function () { 
      $(this).removeClass("swap"); 
      $("ul.display").fadeOut("fast", function() { 
          $(this).fadeIn("fast").addClass("thumb_view"); 
        }); 
    });  

});

not sure if it will work, im just guessin. i dont rly no javascript but i can guess good sometimes :P lol