| Autor | Zpráva | ||
|---|---|---|---|
| alaindelon Profil |
Zdravím. Nevedel by niekto poradiť prečo mi nefunguje kód keď to mám uložené v pc v html.
Ale keď to vložím na stránku http://jsfiddle.net/ tak jedine tam to funguje. <div class="fader"> <div class="a b"><img src="http://placehold.it/300x300/fff000"/><h1>aaa</h1></div> <div class="a c"><img src="http://placehold.it/300x300/ff0000" /><h1>bbb</h1></div> <div class="a d"><img src="http://placehold.it/300x300/00ff00" /><h1>ccc</h1></div> </div> var $imgs = $(".fader").find(".a img"),
i = -1;
function changeImage(){
var next = (++i % $imgs.length);
$($imgs.get(next - 1)).fadeOut(500);
$($imgs.get(next)).fadeIn(500);
}
var interval = setInterval(changeImage, 2000 );#fader.a img {position:absolute;top: 0; left: 0;display: none;}
.a {position:absolute;overflow:hidden;}
.a h1{top:150px;position:absolute;}
.b h1{position:absolute;}
.c h1{position:absolute;}
.d h1 {position:absolute;} |
||
| maks Profil |
alaindelon:
používáš dolar, kde máš přilinkované jQuery? Deklarace .b h1, .c h1 a .d h1 v CSS jsou zbytečné.
|
||
| Alaibdelon Profil * |
#3 · Zasláno: 6. 12. 2013, 08:01:33
Ano,vedel by si poradit?
|
||
| Radek9 Profil |
#4 · Zasláno: 6. 12. 2013, 10:12:11
Alaibdelon:
Co ti vypisuje konzole? Pošli nejlépe celý kód (včetně přilinkování knihoven). |
||
| alaindelon Profil |
Toto mi vypisuje v IE:
HTML1300: Vyskytla sa navigácia. File: index.html HTML1524: Neplatný dokument HTML5 DOCTYPE. Zvážte použitie interoperabilnej formy <!DOCTYPE html>. File: index.html, Line: 1, Column: 1 |
||
| Radek9 Profil |
#6 · Zasláno: 6. 12. 2013, 10:32:45
alaindelon:
Dobře, to je celkem k ničemu. Tak hlavně ten kód. |
||
| alaindelon Profil |
#7 · Zasláno: 6. 12. 2013, 10:37:13
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Dokument bez názvu</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
var $imgs = $("#fader").find(".a img"),
i = -1;
function changeImage(){
var next = (++i % $imgs.length);
$($imgs.get(next - 1)).fadeOut(500);
$($imgs.get(next)).fadeIn(500);
}
var interval = setInterval(changeImage, 2000 );
</script>
<style type="text/css">
#fader.a img {position:absolute;top: 0; left: 0;display: none;}
.a {position:absolute;overflow:hidden;}
.a h1{top:150px;position:absolute;}
.b h1{position:absolute;}
.c h1{position:absolute;}
.d h1 {position:absolute;}
</style>
</head>
<body>
<div id="fader">
<div class="a b"><img src="http://placehold.it/300x300/fff000"/><h1>aaa</h1></div>
<div class="a c"><img src="http://placehold.it/300x300/ff0000" /><h1>bbb</h1></div>
<div class="a d"><img src="http://placehold.it/300x300/00ff00" /><h1>ccc</h1></div>
</div>
</body>
</html> |
||
| Radek9 Profil |
#8 · Zasláno: 6. 12. 2013, 12:09:03
alaindelon:
Dej ten JavaScript až pod ten div s třídou (potažmo s id) fader. |
||
| alaindelon Profil |
#9 · Zasláno: 6. 12. 2013, 23:52:34
Radek9:
Ďakujem, už funguje. |
||
|
Časová prodleva: 13 let
|
|||
0