Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Web Development
You last visited: Today at 07:12

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



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

Discussion on jQuery ... .attr(width) vergleichen ?` within the Web Development forum part of the Coders Den category.

Reply
 
Old   #1
 
Zettabytes*'s Avatar
 
elite*gold: 1
Join Date: Oct 2011
Posts: 660
Received Thanks: 147
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 Code:
<!DOCTYPE html>
<
html>
    <
head>
        <
link rel="stylesheet" type="text/css" href="css/style.css" />
        <
script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script>

    </head>
        <body>

            <div id="loaderbg">
                <div id="balken">
                    <div id="ladebalken"></div>
                    <script language="javascript" type="text/javascript">
                    if($("#ladebalken").attr({"width":"100px"},2000)){
                        $(location).attr('href','home.html');
                    };
                    $(document).ready(function(){
                    $("#ladebalken").animate({
                    width:'300px'
                    },10000);
                    });





                    </script>
                </div>
            </div>


        </body>
</html> 
Dort ist der jQuery Code auch drin.

CSS:
PHP Code:
body {
    
backgroundurl(img/background-intro.jpgno-repeat center center fixed;
    -
webkit-background-sizecover;
    -
moz-background-sizecover;
    -
o-background-sizecover;
    
background-sizecover;
    }

#loaderbg{
    
background-colorwhite;
    
height150px;
    
left50%;
    
margin: -75px auto 0 -200px;
    
opacity0.5;
    
positionabsolute;
    
top50%;
    
width400px;
    
border-radius:15px;
    
box-shadow:2px 13px 3px black;
    }

#balken{
    
height25px;
    
width300px;
    
background-colorwhite;
    
positionabsolute;
    
margin-top: -12.5px;
    
top50%;
    
margin-left: -150px;
    
left:50%;
    
border-radius:10px;
    
border:1px solid black;
    
box-shadow:0 0 3px black;
}

#ladebalken{
    
background-imageurl(img/ladebalken.jpg);
    
height:25px;
    
width0px;
    
positionabsolute;
    
left:50%;
    
top:50%;
    
margin-left: -150px;
    
margin-top: -12.5px;
    
border-radius:10px;

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

Irgendwas will nicht, ... ?!
Ich bekomm es einfach nicht hin mit dem vergleich in jQUery
Zettabytes* is offline  
Old 09/23/2012, 00:59   #2

 
elite*gold: 142
Join Date: Apr 2010
Posts: 859
Received Thanks: 428
Wurde JS nicht immer im Header eingetragen?

Ändere es dochmal so ab das es so ausschaut:
PHP Code:
<!DOCTYPE html>
<
html>
    <
head>
        <
link rel="stylesheet" type="text/css" href="css/style.css" />
        <
script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
         <script language="javascript" type="text/javascript">
                  if($("#ladebalken").attr({"width":"100px"},2000)){
                      $(location).attr('href','home.html');
                  };
                  $(document).ready(function(){
                  $("#ladebalken").animate({
                  width:'300px'
                   },10000);
                  });
          </script>
    </head>
        <body>

            <div id="loaderbg">
                <div id="balken">
                    <div id="ladebalken"></div>

                </div>
            </div>


        </body>
</html> 
Man könnte auch hergehn und das JS in einer Seperaten Datei (zb ladebalken.js) speichern und dann includen

bin zwar nicht so fit in sachen JS aber das sollte afaik richtig sein, wenn nicht bitte nicht schlagen *duck*
mfg
©ross is offline  
Old 09/23/2012, 01:07   #3
 
Zettabytes*'s Avatar
 
elite*gold: 1
Join Date: Oct 2011
Posts: 660
Received Thanks: 147
Quote:
Originally Posted by ©ross View Post
Wurde JS nicht immer im Header eingetragen?

Ändere es dochmal so ab das es so ausschaut:
PHP Code:
<!DOCTYPE html>
<
html>
    <
head>
        <
link rel="stylesheet" type="text/css" href="css/style.css" />
        <
script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
         <script language="javascript" type="text/javascript">
                  if($("#ladebalken").attr({"width":"100px"},2000)){
                      $(location).attr('href','home.html');
                  };
                  $(document).ready(function(){
                  $("#ladebalken").animate({
                  width:'300px'
                   },10000);
                  });
          </script>
    </head>
        <body>

            <div id="loaderbg">
                <div id="balken">
                    <div id="ladebalken"></div>

                </div>
            </div>


        </body>
</html> 
Man könnte auch hergehn und das JS in einer Seperaten Datei (zb ladebalken.js) speichern und dann includen

bin zwar nicht so fit in sachen JS aber das sollte afaik richtig sein, wenn nicht bitte nicht schlagen *duck*
mfg
Ist schon richtig, das mit dem einbinden weis ich, wollte aber nur zu Testzwecken das machen. Ausserdem funtkioniert die Animation auch, nur das es wenn es auf Max. 300px ist es nicht weiterleitet....

PHP Code:
<!DOCTYPE html>
<
html>
    <
head>
        <
link rel="stylesheet" type="text/css" href="css/style.css" />
        <
script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script>

    </head>
        <body>

            <div id="loaderbg">
                <div id="balken">
                    <div id="ladebalken"></div>
                    <script language="javascript" type="text/javascript">

                    $(document).ready(function(){
                    $("#ladebalken").animate({
                    width:'300px'
                    },10000);

                     if($("#ladebalken").attr({"width":}=={"300"},2000)){
                        $(location).attr('href','home.html');
                    };
                    });





                    </script>
                </div>
            </div>


        </body>
</html> 
Zettabytes* is offline  
Old 09/23/2012, 01:52   #4

 
elite*gold: 142
Join Date: Apr 2010
Posts: 859
Received Thanks: 428
chromium sagt
Code:
Uncaught SyntaxError: Unexpected token }
und das zwischen

PHP Code:
if($("#ladebalken").attr({"width":}=={"300"},2000)){ 
und
PHP Code:
                        $(location).attr('href','home.html'); 
©ross is offline  
Old 09/23/2012, 13:08   #5

 
boxxiebabee's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 1,222
Received Thanks: 500
Ich hab sowas vor nicht alt zu langer Zeit hier mal veröffentlicht als JQuery Plugin.
Siehe:

Achja, habs mir jetzt nicht genauer angesehen, aber die überprüfen sollte so aussehen:
Code:
if($("#ladebalken").width()==300)
boxxiebabee is offline  
Old 09/23/2012, 13:34   #6
 
Zettabytes*'s Avatar
 
elite*gold: 1
Join Date: Oct 2011
Posts: 660
Received Thanks: 147
Quote:
Originally Posted by boxxiebabee View Post
Ich hab sowas vor nicht alt zu langer Zeit hier mal veröffentlicht als JQuery Plugin.
Siehe:

Achja, habs mir jetzt nicht genauer angesehen, aber die überprüfen sollte so aussehen:
Code:
if($("#ladebalken").width()==300)
Hey,

danke, aber momentan möchte ich aus Lernzwecke ganz einfach dinge wie diese selbst realisieren ohne ein Plugin.

Ich werde es versuchen.
Zettabytes* is offline  
Old 09/23/2012, 21:34   #7

 
boxxiebabee's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 1,222
Received Thanks: 500
Quote:
Originally Posted by Zettabytes* View Post
Hey,

danke, aber momentan möchte ich aus Lernzwecke ganz einfach dinge wie diese selbst realisieren ohne ein Plugin.

Ich werde es versuchen.
Und die überprüfung sollte immer nur dann statt finden wenn sich die Weite von der Progressbar ändert, sonst hat es keinen Sinn.
boxxiebabee is offline  
Old 09/23/2012, 22:43   #8
 
Zettabytes*'s Avatar
 
elite*gold: 1
Join Date: Oct 2011
Posts: 660
Received Thanks: 147
Quote:
Originally Posted by boxxiebabee View Post
Und die überprüfung sollte immer nur dann statt finden wenn sich die Weite von der Progressbar ändert, sonst hat es keinen Sinn.
Tut es sich ja, es geht von 0px auf 300px, wenn die 300px erreicht sind, sollte eine Umleitung auf eine andere Seite erzeugt werden. Leider blicke ich bei jQuery nicht wie das mit dem IF und die Syntax funktioniert, habe versucht das nachzulesen, leider versteh ich immer nicht was die da erzählen.
Zettabytes* is offline  
Old 09/24/2012, 02:38   #9

 
boxxiebabee's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 1,222
Received Thanks: 500
Kannst du denn schon überhaupt normales Javascript? Das solltest auf jeden Fall schon vorher können, zumindest mal die grundlegendsten Sachen bevor du dich an ein Framework ranmachst.
boxxiebabee is offline  
Old 09/24/2012, 08:59   #10
 
Zettabytes*'s Avatar
 
elite*gold: 1
Join Date: Oct 2011
Posts: 660
Received Thanks: 147
Nein kann ich nicht. Nichtmal ansatzsweise. xD
Zettabytes* is offline  
Old 09/24/2012, 14:38   #11

 
boxxiebabee's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 1,222
Received Thanks: 500
Dann lern erstmal Javascript.. :>
boxxiebabee is offline  
Old 09/24/2012, 17:08   #12
Administrator
 
Muddy Waters's Avatar
 
elite*gold: 41364
Join Date: Jan 2010
Posts: 22,727
Received Thanks: 12,653
Ich würde dir auch raten, erstmal JS zu lernen, eine schöne Einführung findest du z.B. .

Dein Beispiel funktioniert so schon fast, man merkt aber an einigen Stellen durchaus, dass du scheinbar mit zwei verbundenen Augen an die Sache herangehst oder zumindest mal keine Ahnung hast, was du eigentlich machst. So wie ich deine Problemstellung verstanden habe brauchst du jedenfalls keine Breite vergleichen. Du gibst bei der Animation schließlich schon den Endwert von 300px vor, es reicht also wenn du einen Callback Handler zuweist, also eine Funktion, die aufgerufen wird, sobald die Animation beendet ist.

Das sieht dann so aus (CSS habe ich minimal abgeändert, damit es auch ohne Bild klappt):
Muddy Waters is offline  
Thanks
1 User
Reply


Similar Threads Similar Threads
[Question] CSS HTML Width Problem
04/25/2012 - Web Development - 2 Replies
Hey everyone... so I'm having a weird problem with scrolling. Sorry if this is easy to figure out, this is my first css website. If I shrink my browser's size down to where my website needs scroll bars, the html container doesn't expand. I tried setting it to 100% width, but nothing happened. It only happens in non-traditional browsers (everything but IE for a change). http://i1212.photobucket.com/albums/cc447/Spirite dFang/problem-1.png Here's my CSS code: body { background-image:...
[Help] Getting Length and Width of the DMaps
08/03/2010 - CO2 Private Server - 3 Replies
I use spatial indexing for my server, which could be optimized a little, by adding the length and width of each map. I know it can be read from the map files, or some different file for sure, but I do not know how to do this, as I have no experience with maps. What I want is a simple text file including: MapID - X or Width - Y or Length where - is a space, so: 1002 1024 1024 I need this for all maps except for special maps such as houses, ships, new maps, explaining me how to do it...
pointer of width and size of pg
07/24/2010 - 4Story - 11 Replies
hi guys, i'm looking for a pointer (or maybe they are two..) i just want to know the width and the size of my character..i've tried several scan with CE but i've not find out.. can someone help?? thanks translated with google translate : hallo Jungs, ich bin für einen Zeiger (oder vielleicht sind sie zwei suchen ..)
attr.attr wo ist die datei
06/21/2010 - Metin2 Private Server - 1 Replies
Wo finde ich die attr.attr Datei und die andere also die wtr oder wie die heißt
[help]how to change body width?
01/19/2009 - Perfect World - 1 Replies
i have look many character with body unusual and i have some tutorial from cheatngine.org but didnt work like this bodyID = 0 colorBody = -16053469 headScale = 1000



All times are GMT +1. The time now is 07:12.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.