si les déclarations en jQuery

  • mindfullsilence
  • Professor
  • Professor
  • Avatar de l’utilisateur
  • Inscription: Aoû 04, 2008
  • Messages: 846
  • Status: Offline

Message Décembre 6th, 2009, 9:35 pm

Je veux donc vérifier si la largeur des éléments est défini comme 500px dans le css. S'il l'est, puis faites en croissance. S'il n'y est pas, réduire ensuite à 500px. Quelqu'un sait comment faire cela?
Use your words like arrows to shoot toward your goal.
  • Anonymous
  • Bot
  • No Avatar
  • Inscription: 25 Feb 2008
  • Messages: ?
  • Loc: Ozzuland
  • Status: Online

Message Décembre 6th, 2009, 9:35 pm

  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Inscription: Fév 10, 2004
  • Messages: 13455
  • Loc: Florida
  • Status: Offline

Message Décembre 6th, 2009, 10:08 pm

Im guessing vous parlons d'un des éléments largeur actuelle,
http://docs.jquery.com/CSS/css#name

Par croître im guessing vous le souhaitez d'animer?
http://docs.jquery.com/Effects/animate# ... ngcallback
Strong with this one, the sudo is.
  • mindfullsilence
  • Professor
  • Professor
  • Avatar de l’utilisateur
  • Inscription: Aoû 04, 2008
  • Messages: 846
  • Status: Offline

Message Décembre 6th, 2009, 10:11 pm

okay, j'ai pensé à cette partie, jQuery a "width ()". Whoda thunk. Maintenant, mon problème est que ma déclaration ne fait rien d'autre, et il semble que si ma déclaration ne fait que se répéter.

JAVASCRIPT Code: [ Select ]
var m = $("#imagecontainer img").width();
 
if (m == 500)
  {
 
  $("#imagelink").click(function(){
         $("#imagecontainer")
         
         .css(
            {
                  position : "absolute",
                  marginLeft : "auto",
                  marginRight : "auto",
                  zIndex : "2",
                  left : "0px",
                  width : "100%"
            })
         
         .animate(
            {
                  height : "80%",
                  marginTop : "-40px",
            }, 300 );
         
         
         $("#imagecontainer img")
         
         .animate(
            {
                  height : "100%",
            }, 300 )
         
         .css(
            {
                  width : "auto",
            });              
   });
  }
 
else {
   
   $("#imagecontainer").click(function(){
         $("#imagecontainer")
         
         .css(
            {
                  position : "relative",
                  marginLeft : "auto",
                  marginRight : "auto",
                  zIndex : "1",
                  left : "0px",
                  width : "500px",
                  height : "auto",
            })
         
         .animate(
            {
                  width : "500px",
                  marginTop : "0px",
            }, 300 );
         
         
         $("#imagecontainer img")
         
         .animate(
            {
                  height : "100%",
            }, 300 )
         
         .css(
            {
                  width : "auto",
            });              
   });
 
  }
   
});
 
  1. var m = $("#imagecontainer img").width();
  2.  
  3. if (m == 500)
  4.   {
  5.  
  6.   $("#imagelink").click(function(){
  7.          $("#imagecontainer")
  8.          
  9.          .css(
  10.             {
  11.                   position : "absolute",
  12.                   marginLeft : "auto",
  13.                   marginRight : "auto",
  14.                   zIndex : "2",
  15.                   left : "0px",
  16.                   width : "100%"
  17.             })
  18.          
  19.          .animate(
  20.             {
  21.                   height : "80%",
  22.                   marginTop : "-40px",
  23.             }, 300 );
  24.          
  25.          
  26.          $("#imagecontainer img")
  27.          
  28.          .animate(
  29.             {
  30.                   height : "100%",
  31.             }, 300 )
  32.          
  33.          .css(
  34.             {
  35.                   width : "auto",
  36.             });              
  37.    });
  38.   }
  39.  
  40. else {
  41.    
  42.    $("#imagecontainer").click(function(){
  43.          $("#imagecontainer")
  44.          
  45.          .css(
  46.             {
  47.                   position : "relative",
  48.                   marginLeft : "auto",
  49.                   marginRight : "auto",
  50.                   zIndex : "1",
  51.                   left : "0px",
  52.                   width : "500px",
  53.                   height : "auto",
  54.             })
  55.          
  56.          .animate(
  57.             {
  58.                   width : "500px",
  59.                   marginTop : "0px",
  60.             }, 300 );
  61.          
  62.          
  63.          $("#imagecontainer img")
  64.          
  65.          .animate(
  66.             {
  67.                   height : "100%",
  68.             }, 300 )
  69.          
  70.          .css(
  71.             {
  72.                   width : "auto",
  73.             });              
  74.    });
  75.  
  76.   }
  77.    
  78. });
  79.  


Im deviner si j'ai besoin de boucle de retour au haut de la fonction après avoir exécuté les paramètres fixés par la fonction si. Est-ce exact? si sio, comment voulez-vous lui dire de vérifier une variable de nouveau?
Use your words like arrows to shoot toward your goal.
  • mindfullsilence
  • Professor
  • Professor
  • Avatar de l’utilisateur
  • Inscription: Aoû 04, 2008
  • Messages: 846
  • Status: Offline

Message Décembre 6th, 2009, 10:21 pm

okay, j'ai vraiment besoin de la recherche en réalité un peu plus que je suis annonce avant que les questions, lol. regarde si, comme si je viens de mettre l'instruction if ailleurs à l'intérieur de mon cas, cela fonctionne. heres le nouveau code si vous êtes curieux:

JAVASCRIPT Code: [ Select ]
$(document).ready(function(){
 
 
 
 
  $("#imagelink").click(function(){
      var m = $("#imagecontainer img").width();
     
      if (m == 500)
         {
         $("#imagecontainer")
         
         .css(
            {
                  position : "absolute",
                  marginLeft : "auto",
                  marginRight : "auto",
                  zIndex : "2",
                  left : "0px",
                  width : "100%"
            })
         
         .animate(
            {
                  height : "80%",
                  marginTop : "-40px",
            }, 300 );
         
         
         $("#imagecontainer img")
         
         .animate(
            {
                  height : "100%",
            }, 300 )
         
         .css(
            {
                  width : "auto",
            });
         } 
         
      else
         {
   
         $("#imagecontainer").click(function(){
         $("#imagecontainer")
         
         .css(
            {
                  position : "relative",
                  marginLeft : "auto",
                  marginRight : "auto",
                  zIndex : "1",
                  left : "0px",
                  width : "500px",
                  height : "auto",
            })
         
         .animate(
            {
                  width : "500px",
                  marginTop : "0px",
            }, 300 );
         
         
         $("#imagecontainer img")
         
         .animate(
            {
                  width : "500px",
            }, 300 )
         
         .css(
            {
                  height : "auto",
            });              
   });
 
  }          
   });
 
 
 
   
});
 
  1. $(document).ready(function(){
  2.  
  3.  
  4.  
  5.  
  6.   $("#imagelink").click(function(){
  7.       var m = $("#imagecontainer img").width();
  8.      
  9.       if (m == 500)
  10.          {
  11.          $("#imagecontainer")
  12.          
  13.          .css(
  14.             {
  15.                   position : "absolute",
  16.                   marginLeft : "auto",
  17.                   marginRight : "auto",
  18.                   zIndex : "2",
  19.                   left : "0px",
  20.                   width : "100%"
  21.             })
  22.          
  23.          .animate(
  24.             {
  25.                   height : "80%",
  26.                   marginTop : "-40px",
  27.             }, 300 );
  28.          
  29.          
  30.          $("#imagecontainer img")
  31.          
  32.          .animate(
  33.             {
  34.                   height : "100%",
  35.             }, 300 )
  36.          
  37.          .css(
  38.             {
  39.                   width : "auto",
  40.             });
  41.          } 
  42.          
  43.       else
  44.          {
  45.    
  46.          $("#imagecontainer").click(function(){
  47.          $("#imagecontainer")
  48.          
  49.          .css(
  50.             {
  51.                   position : "relative",
  52.                   marginLeft : "auto",
  53.                   marginRight : "auto",
  54.                   zIndex : "1",
  55.                   left : "0px",
  56.                   width : "500px",
  57.                   height : "auto",
  58.             })
  59.          
  60.          .animate(
  61.             {
  62.                   width : "500px",
  63.                   marginTop : "0px",
  64.             }, 300 );
  65.          
  66.          
  67.          $("#imagecontainer img")
  68.          
  69.          .animate(
  70.             {
  71.                   width : "500px",
  72.             }, 300 )
  73.          
  74.          .css(
  75.             {
  76.                   height : "auto",
  77.             });              
  78.    });
  79.  
  80.   }          
  81.    });
  82.  
  83.  
  84.  
  85.    
  86. });
  87.  
Use your words like arrows to shoot toward your goal.
  • mindfullsilence
  • Professor
  • Professor
  • Avatar de l’utilisateur
  • Inscription: Aoû 04, 2008
  • Messages: 846
  • Status: Offline

Message Décembre 6th, 2009, 10:42 pm

Cela n'a pas de sens pour moi, Voici un exemple. Cliquez sur l'image, puis cliquez à nouveau. Tout fonctionne à la manière dont ses censé le faire. MAIS, si vous cliquez une troisième fois, tout cela est gâché.
Par exemple
Use your words like arrows to shoot toward your goal.
  • UPSGuy
  • Lurker ಠ_ಠ
  • Web Master
  • Avatar de l’utilisateur
  • Inscription: Juil 25, 2005
  • Messages: 2735
  • Loc: Nashville, TN
  • Status: Offline

Message Décembre 7th, 2009, 6:38 am

Je peux agrandir l'image à l'intérieur et à plusieurs reprises. Whats the question?
I'd love to change the world, but they won't give me the source code.
  • mindfullsilence
  • Professor
  • Professor
  • Avatar de l’utilisateur
  • Inscription: Aoû 04, 2008
  • Messages: 846
  • Status: Offline

Message Décembre 7th, 2009, 10:51 am

Désolé, j'ai oublié de vous laisser les gars savent que je le fixe. J'ai décidé d'aller avec un div overlay au lieu d'une instruction if. cliquez sur l'image et la superposition apparaît et anime, cliquez sur la superposition et s'écrouler.
Use your words like arrows to shoot toward your goal.

Afficher de l'information

  • Total des messages de ce sujet: 7 messages
  • Utilisateurs parcourant ce forum: ScottG et 187 invités
  • Vous ne pouvez pas poster de nouveaux sujets
  • Vous ne pouvez pas répondre aux sujets
  • Vous ne pouvez pas éditer vos messages
  • Vous ne pouvez pas supprimer vos messages
  • Vous ne pouvez pas joindre des fichiers
 
 

© 2011 Unmelted, LLC. Ozzu® est une marque déposée de Unmelted, LLC