Einzelnen Beitrag anzeigen
  #4 (permalink)  
Alt 03.02.2020, 17:42
Iago2 Iago2 ist offline
Benutzer
neuer user
Thread-Ersteller
 
Registriert seit: 13.09.2005
Beiträge: 83
Iago2 befindet sich auf einem aufstrebenden Ast
Standard

Zitat:
Zitat von cloned Beitrag anzeigen
Wieso willst du es dir selber so kompliziert machen?
Wenn du 10 buttons hast die etwas ein- ausblenden sollen schreibst du dann 100 verschiedene Varianten fix in deinen Code?
Wenn man gerne schreibt

Der Counter funktioniert, auch die Werte in tempWidth stimmen, trotzdem noch keine richtige Darstellung:

HTML-Code:
// HTML Button
    
    $("#HTML-B").click(function() {		
		
	
		//toggle
		
		if(HTMLb == false) { 
			$("#HTML-B").css("background","rgb(244,250,88)");		
			HTMLb = true;
			
			counter++; 
			$("#count").html(counter);
			
			tempWidth = 100/counter;
		
			$("#accordion li:first").css("width",tempWidth+"%");
			// alert(tempWidth);
			}		
			
		else { 		
			$("#HTML-B").css("background","rgb(208,219,224)");		
			HTMLb = false; 
			counter--;
			$("#count").html(counter);
			
			$("#accordion li:first").css("width","0px");
			
			// alert(tempWidth);		
			
			}	
				
		
	});

		// CSS Button :nth-of-type(2)
	
	 $("#CSS-B").click(function() {	
		 
				  
		 //toggle
		 	 			 
		if(CSSb == false) { 
			$("#CSS-B").css("background","rgb(244,250,88)");	
				CSSb = true; 
				counter++;	
				$("#count").html(counter);
				
				tempWidth = 100/counter;
			
				$("#accordion li:nth-of-type(2)").css("width",tempWidth+"%");
				// alert(tempWidth);						
				}		
				
		
		else { 		
			$("#CSS-B").css("background","rgb(208,219,224)");
				CSSb = false;
				counter--; 				
				$("#count").html(counter);
		
				$("#accordion li:nth-of-type(2)").css("width","0px");
				// alert(tempWidth);
				
				 }		
	
	});
	
	
	// JS Button :nth-of-type(3)
	
	$("#JS-B").click(function() {
			
		//toggle
				
		if(JSb == false) { 
			$("#JS-B").css("background","rgb(244,250,88)");
			JSb = true; 
			counter++; 		
			
			$("#count").html(counter);	
			
			tempWidth = 100/counter;
			
			$("#accordion li:nth-of-type(3)").css("width",tempWidth+"%");
			
			// alert(tempWidth);
					
			}		
			
		else { 		
			$("#JS-B").css("background","rgb(208,219,224)");
			JSb = false; 
			counter--;			
					
			$("#count").html(counter);
			 
			 $("#accordion li:nth-of-type(3)").css("width","0px");
			
			// alert(tempWidth);
			
			}	
	});
	
	// Output Button li:last
		
	$("#output-B").click(function() {
			
		//toggle
		
		if(OUTb == false) { 
			$("#output-B").css("background","rgb(244,250,88)");
			
			OUTb = true; 		
			counter++; 		
			$("#count").html(counter);
			
			tempWidth = 100/counter;
			
			$("#accordion li:last").css("width",tempWidth+"%");
			
			// alert(tempWidth);
			
			}		
			
		else { 		
			$("#output-B").css("background","rgb(208,219,224)");
			
			OUTb = false; 
			counter--;		
			$("#count").html(counter);
			
			$("#accordion li:last").css("width","0px");
			
			// alert(tempWidth);
	
			}	
	});
	
	
	});
Mit Zitat antworten