jQuery ... .attr(width) vergleichen ?`

    Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

    • jQuery ... .attr(width) vergleichen ?`

      Hallo,

      bin anfänger in jQuery. Möchte eine Progressbar machen, wenn width==300px hat soll es auf eine andere Seite laden.

      Mein HTML Code:

      PHP-Quellcode

      1. <!DOCTYPE html>
      2. <html>
      3. <head>
      4. <link rel="stylesheet" type="text/css" href="css/style.css" />
      5. <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
      6. </head>
      7. <body>
      8. <div id="loaderbg">
      9. <div id="balken">
      10. <div id="ladebalken"></div>
      11. <script language="javascript" type="text/javascript">
      12. if($("#ladebalken").attr({"width":"100px"},2000)){
      13. $(location).attr('href','home.html');
      14. };
      15. $(document).ready(function(){
      16. $("#ladebalken").animate({
      17. width:'300px'
      18. },10000);
      19. });
      20. </script>
      21. </div>
      22. </div>
      23. </body>
      24. </html>
      Alles anzeigen


      Dort ist der jQuery Code auch drin.

      CSS:

      PHP-Quellcode

      1. body {
      2. background: url(img/background-intro.jpg) no-repeat center center fixed;
      3. -webkit-background-size: cover;
      4. -moz-background-size: cover;
      5. -o-background-size: cover;
      6. background-size: cover;
      7. }
      8. #loaderbg{
      9. background-color: white;
      10. height: 150px;
      11. left: 50%;
      12. margin: -75px auto 0 -200px;
      13. opacity: 0.5;
      14. position: absolute;
      15. top: 50%;
      16. width: 400px;
      17. border-radius:15px;
      18. box-shadow:2px 13px 3px black;
      19. }
      20. #balken{
      21. height: 25px;
      22. width: 300px;
      23. background-color: white;
      24. position: absolute;
      25. margin-top: -12.5px;
      26. top: 50%;
      27. margin-left: -150px;
      28. left:50%;
      29. border-radius:10px;
      30. border:1px solid black;
      31. box-shadow:0 0 3px black;
      32. }
      33. #ladebalken{
      34. background-image: url(img/ladebalken.jpg);
      35. height:25px;
      36. width: 0px;
      37. position: absolute;
      38. left:50%;
      39. top:50%;
      40. margin-left: -150px;
      41. margin-top: -12.5px;
      42. border-radius:10px;
      43. }
      Alles anzeigen


      #ladebalken ist das was überprüft werden soll...

      Irgendwas will nicht, ... ?!

      Ich bekomm es einfach nicht hin mit dem vergleich in jQUery
    • Werbung zur Unterstützung des Forums ( Bitte AddBlocker deaktivieren )

    • Ist zwar nicht meine Art hier alles auf dem Silbertablett zu servieren. Aber heute ist Sonntag da mach ich eine Ausnahme.

      HTML-Quellcode

      1. <!DOCTYPE HTML>
      2. <html lang="en-US">
      3. <head>
      4. <meta charset="UTF-8">
      5. <title></title>
      6. <!--<link rel="stylesheet" type="text/css" href="css/style.css" />-->
      7. <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
      8. </head>
      9. <body>
      10. <div id="loaderbg">
      11. <div id="balken">
      12. <div id="ladebalken" data-width="400" style="background: red; height: 25px;"></div>
      13. </div>
      14. </div>
      15. <script type="text/javascript">
      16. // Name des Div's
      17. var ladebalken = $('#ladebalken');
      18. // Standard Width auslesen
      19. var width = ladebalken.attr('data-width');
      20. // Div auf ein Minus Width setzten damit es sich richtig aufbauen kann
      21. ladebalken.css({'width' : '-1px'});
      22. // Div Animieren
      23. ladebalken.animate({
      24. 'width' : width+'px'
      25. }, 10000, function(){
      26. // Falls breite == Wert ist dann umleiten
      27. // Könnte man auch auf ein breite > Wert machen damit es immer geht auch wenn es breiter ist
      28. if(width == '400')
      29. {
      30. window.location.href = 'http://google.de';
      31. }
      32. });
      33. </script>
      34. </body>
      35. </html>
      Alles anzeigen


      Ich hoffe du kommst damit klar. Bei Fragen - jQuery: The Write Less, Do More, JavaScript Library :P