PSD-Tutorials.de
Forum für Design, Fotografie & Bildbearbeitung
Tutkit
Agentur
Hilfe
Kontakt
Start
Forum
Aktuelles
Besonderer Inhalt
Foren durchsuchen
Tutorials
News
Anmelden
Kostenlos registrieren
Aktuelles
Suche
Suche
Nur Titel durchsuchen
Von:
Menü
Anmelden
Kostenlos registrieren
App installieren
Installieren
JavaScript ist deaktiviert. Für eine bessere Darstellung aktiviere bitte JavaScript in deinem Browser, bevor du fortfährst.
Du verwendest einen veralteten Browser. Es ist möglich, dass diese oder andere Websites nicht korrekt angezeigt werden.
Du solltest ein Upgrade durchführen oder einen
alternativen Browser
verwenden.
Antworten auf deine Fragen:
Neues Thema erstellen
Start
Forum
Sonstiges
Webdesign, Webentwicklung & Programmierung
Webdesign: HTML/CSS, Responsive Design, Sass...
Script auslagern - was mach ich falsch
Beitrag
<blockquote data-quote="TommiH" data-source="post: 2144490" data-attributes="member: 450748"><p>Hallo,</p><p></p><p>ich habe eine html5 Seite erstellt zum üben und baue einige sachen ein. darunter auch eine Funktion.</p><p>Wenn sie im html code steht - funktioniert es. nun wollte ich sie auslagern,aber irgend was mache ich falsch <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile :)" loading="lazy" data-shortname=":)" /></p><p></p><p>html Teil mit Funktion (welche funktioniert)</p><p>[HTML]</p><p><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script></p><p> <script type="text/javascript" src="jquery.easing.1.3.js"></script></p><p> <script type="text/javascript"></p><p> $(function() {</p><p> /**</p><p> * for each menu element, on mouseenter, </p><p> * we enlarge the image, and show both sdt_active span and </p><p> * sdt_wrap span. If the element has a sub menu (sdt_box),</p><p> * then we slide it - if the element is the last one in the menu</p><p> * we slide it to the left, otherwise to the right</p><p> */</p><p> $('#sdt_menu > li').bind('mouseenter',function(){</p><p> var $elem = $(this);</p><p> $elem.find('img')</p><p> .stop(true)</p><p> .animate({</p><p> 'width':'170px',</p><p> 'height':'170px',</p><p> 'left':'0px'</p><p> },400,'easeOutBack')</p><p> .andSelf()</p><p> .find('.sdt_wrap')</p><p> .stop(true)</p><p> .animate({'top':'140px'},500,'easeOutBack')</p><p> .andSelf()</p><p> .find('.sdt_active')</p><p> .stop(true)</p><p> .animate({'height':'170px'},300,function(){</p><p> var $sub_menu = $elem.find('.sdt_box');</p><p> if($sub_menu.length){</p><p> var left = '170px';</p><p> if($elem.parent().children().length == $elem.index()+1)</p><p> left = '-170px';</p><p> $sub_menu.show().animate({'left':left},200);</p><p> } </p><p> });</p><p> }).bind('mouseleave',function(){</p><p> var $elem = $(this);</p><p> var $sub_menu = $elem.find('.sdt_box');</p><p> if($sub_menu.length)</p><p> $sub_menu.hide().css('left','0px');</p><p> </p><p> $elem.find('.sdt_active')</p><p> .stop(true)</p><p> .animate({'height':'0px'},300)</p><p> .andSelf().find('img')</p><p> .stop(true)</p><p> .animate({</p><p> 'width':'0px',</p><p> 'height':'0px',</p><p> 'left':'85px'},400)</p><p> .andSelf()</p><p> .find('.sdt_wrap')</p><p> .stop(true)</p><p> .animate({'top':'25px'},500);</p><p> });</p><p> });</p><p> </script>[/HTML]</p><p>habe nun wie folgt ausgelagert</p><p>eine main.js erstellt und im gleichen Verzeichnis wie html abgelegt</p><p>Inhalt:</p><p>[CODE]</p><p><!-- The JavaScript --></p><p></p><p></p><p> $(function() {</p><p> /**</p><p> * for each menu element, on mouseenter, </p><p> * we enlarge the image, and show both sdt_active span and </p><p> * sdt_wrap span. If the element has a sub menu (sdt_box),</p><p> * then we slide it - if the element is the last one in the menu</p><p> * we slide it to the left, otherwise to the right</p><p> */</p><p> $('#sdt_menu > li').bind('mouseenter',function(){</p><p> var $elem = $(this);</p><p> $elem.find('img')</p><p> .stop(true)</p><p> .animate({</p><p> 'width':'170px',</p><p> 'height':'170px',</p><p> 'left':'0px'</p><p> },400,'easeOutBack')</p><p> .andSelf()</p><p> .find('.sdt_wrap')</p><p> .stop(true)</p><p> .animate({'top':'140px'},500,'easeOutBack')</p><p> .andSelf()</p><p> .find('.sdt_active')</p><p> .stop(true)</p><p> .animate({'height':'170px'},300,function(){</p><p> var $sub_menu = $elem.find('.sdt_box');</p><p> if($sub_menu.length){</p><p> var left = '170px';</p><p> if($elem.parent().children().length == $elem.index()+1)</p><p> left = '-170px';</p><p> $sub_menu.show().animate({'left':left},200);</p><p> } </p><p> });</p><p> }).bind('mouseleave',function(){</p><p> var $elem = $(this);</p><p> var $sub_menu = $elem.find('.sdt_box');</p><p> if($sub_menu.length)</p><p> $sub_menu.hide().css('left','0px');</p><p> </p><p> $elem.find('.sdt_active')</p><p> .stop(true)</p><p> .animate({'height':'0px'},300)</p><p> .andSelf().find('img')</p><p> .stop(true)</p><p> .animate({</p><p> 'width':'0px',</p><p> 'height':'0px',</p><p> 'left':'85px'},400)</p><p> .andSelf()</p><p> .find('.sdt_wrap')</p><p> .stop(true)</p><p> .animate({'top':'25px'},500);</p><p> });</p><p> });</p><p></p><p>[/CODE]</p><p>und im [HTML] </p><p><head></p><p> .......</p><p> <script language="JavaScript" type="text/javascript" src="js/main.js"></script></p><p> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script></p><p></head></p><p>[/HTML]</p><p>Bestimmt ein Anfängerfehler.</p><p></p><p>Sorry</p><p></p><p>Danke und Grüße</p><p></p><p>tommih</p></blockquote><p></p>
[QUOTE="TommiH, post: 2144490, member: 450748"] Hallo, ich habe eine html5 Seite erstellt zum üben und baue einige sachen ein. darunter auch eine Funktion. Wenn sie im html code steht - funktioniert es. nun wollte ich sie auslagern,aber irgend was mache ich falsch :) html Teil mit Funktion (welche funktioniert) [HTML] <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="jquery.easing.1.3.js"></script> <script type="text/javascript"> $(function() { /** * for each menu element, on mouseenter, * we enlarge the image, and show both sdt_active span and * sdt_wrap span. If the element has a sub menu (sdt_box), * then we slide it - if the element is the last one in the menu * we slide it to the left, otherwise to the right */ $('#sdt_menu > li').bind('mouseenter',function(){ var $elem = $(this); $elem.find('img') .stop(true) .animate({ 'width':'170px', 'height':'170px', 'left':'0px' },400,'easeOutBack') .andSelf() .find('.sdt_wrap') .stop(true) .animate({'top':'140px'},500,'easeOutBack') .andSelf() .find('.sdt_active') .stop(true) .animate({'height':'170px'},300,function(){ var $sub_menu = $elem.find('.sdt_box'); if($sub_menu.length){ var left = '170px'; if($elem.parent().children().length == $elem.index()+1) left = '-170px'; $sub_menu.show().animate({'left':left},200); } }); }).bind('mouseleave',function(){ var $elem = $(this); var $sub_menu = $elem.find('.sdt_box'); if($sub_menu.length) $sub_menu.hide().css('left','0px'); $elem.find('.sdt_active') .stop(true) .animate({'height':'0px'},300) .andSelf().find('img') .stop(true) .animate({ 'width':'0px', 'height':'0px', 'left':'85px'},400) .andSelf() .find('.sdt_wrap') .stop(true) .animate({'top':'25px'},500); }); }); </script>[/HTML] habe nun wie folgt ausgelagert eine main.js erstellt und im gleichen Verzeichnis wie html abgelegt Inhalt: [CODE] <!-- The JavaScript --> $(function() { /** * for each menu element, on mouseenter, * we enlarge the image, and show both sdt_active span and * sdt_wrap span. If the element has a sub menu (sdt_box), * then we slide it - if the element is the last one in the menu * we slide it to the left, otherwise to the right */ $('#sdt_menu > li').bind('mouseenter',function(){ var $elem = $(this); $elem.find('img') .stop(true) .animate({ 'width':'170px', 'height':'170px', 'left':'0px' },400,'easeOutBack') .andSelf() .find('.sdt_wrap') .stop(true) .animate({'top':'140px'},500,'easeOutBack') .andSelf() .find('.sdt_active') .stop(true) .animate({'height':'170px'},300,function(){ var $sub_menu = $elem.find('.sdt_box'); if($sub_menu.length){ var left = '170px'; if($elem.parent().children().length == $elem.index()+1) left = '-170px'; $sub_menu.show().animate({'left':left},200); } }); }).bind('mouseleave',function(){ var $elem = $(this); var $sub_menu = $elem.find('.sdt_box'); if($sub_menu.length) $sub_menu.hide().css('left','0px'); $elem.find('.sdt_active') .stop(true) .animate({'height':'0px'},300) .andSelf().find('img') .stop(true) .animate({ 'width':'0px', 'height':'0px', 'left':'85px'},400) .andSelf() .find('.sdt_wrap') .stop(true) .animate({'top':'25px'},500); }); }); [/CODE] und im [HTML] <head> ....... <script language="JavaScript" type="text/javascript" src="js/main.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> </head> [/HTML] Bestimmt ein Anfängerfehler. Sorry Danke und Grüße tommih [/QUOTE]
Bilder bitte
hier hochladen
und danach über das Bild-Icon (Direktlink vorher kopieren) platzieren.
Zitate einfügen…
Authentifizierung
Wenn ▲ = 7, ▼ = 3, ◇ = 2 und die Summe von ▲ und ▼ durch ◇ geteilt wird, was ist das Ergebnis?
Antworten
Start
Forum
Sonstiges
Webdesign, Webentwicklung & Programmierung
Webdesign: HTML/CSS, Responsive Design, Sass...
Script auslagern - was mach ich falsch
Oben