Manual Slideshow
Manual Slideshow
Example
<img class="mySlides" src="img_fjords.jpg">
<img class="mySlides" src="img_lights.jpg">
<img class="mySlides" src="img_mountains.jpg">
<img class="mySlides" src="img_forest.jpg">
Example
<a class="w3-btn-floating" onclick="plusDivs(-1)">❮</a>
<a class="w3-btn-floating" onclick="plusDivs(+1)">❯</a>
Example
var slideIndex = 1;
showDivs(slideIndex);
function plusDivs(n) {
showDivs(slideIndex += n);
}
function showDivs(n) {
var i;
var x = document.getElementsByClassName("mySlides");
if (n > x.length) {slideIndex = 1}
if (n < 1) {slideIndex = x.length} ;
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
x[slideIndex-1].style.display = "block";
}
Try It Yourself
JavaScript Explained
First, set the slideIndex to 1. (First picture)
Example
var slideIndex = 0;
carousel();
function carousel() {
var i;
var x = document.getElementsByClassName("mySlides");
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
slideIndex++;
if (slideIndex > x.length) {slideIndex = 1}
x[slideIndex-1].style.display = "block";
setTimeout(carousel, 2000); // Change image every 2 seconds
}
Try It Yourself
<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<body>
</div>
<script>
var slideIndex = 1;
showDivs(slideIndex);
function plusDivs(n) {
showDivs(slideIndex += n);
}
function showDivs(n) {
var i;
var x = document.getElementsByClassName("mySlides");
if (n > x.length) {slideIndex = 1}
if (n < 1) {slideIndex = x.length}
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
x[slideIndex-1].style.display = "block";
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<style>
.mySlides {display:none;}
</style>
<body>
<script>
var myIndex = 0;
carousel();
function carousel() {
var i;
var x = document.getElementsByClassName("mySlides");
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
myIndex++;
if (myIndex > x.length) {myIndex = 1}
x[myIndex-1].style.display = "block";
setTimeout(carousel, 2000); // Change image every 2 seconds
}
</script>
</body>
</html>
HTML Slides
The slides do not have to be images.
Slide 3
Lorem ipsum
Example
<div class="mySlides">
<div class="w3-container w3-red">
<h1><b>Did You Know?</b></h1>
<h1><i>We plan to sell trips to the moon in the 2020s</i></h1>
</div>
Try It Yourself
<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<style>
.mySlides {display:none;}
</style>
<body>
<h2 class="w3-center">HTML slides</h2>
</div>
<script>
var slideIndex = 0;
carousel();
function carousel() {
var i;
var x = document.getElementsByClassName("mySlides");
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
slideIndex++;
if (slideIndex > x.length) {slideIndex = 1}
x[slideIndex-1].style.display = "block";
setTimeout(carousel, 2000);
}
</script>
</body>
</html>
Slideshow Caption
Trolltunga, Norway
Add a caption text for each image slide with the w3-display-* classes
(topleft, topmiddle, topright, bottomleft, bottommiddle, bottomright or
middle):
Example
<div class="w3-display-container mySlides">
<img src="img_fjords.jpg" style="width:100%">
<div class="w3-display-bottomleft w3-container w3-padding-16 w3-
black">
Trolltunga, Norway
</div>
</div>
Try It Yourself
<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<body>
<div class="w3-container">
<h2>Slideshow Caption</h2>
<p>Add a caption text for each image slide with the w3-display-* classes
(topleft, topmiddle, topright, bottomleft, bottommiddle, bottomright or
middle).</p>
</div>
</div>
<script>
var slideIndex = 1;
showDivs(slideIndex);
function plusDivs(n) {
showDivs(slideIndex += n);
}
function showDivs(n) {
var i;
var x = document.getElementsByClassName("mySlides");
if (n > x.length) {slideIndex = 1}
if (n < 1) {slideIndex = x.length}
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
x[slideIndex-1].style.display = "block";
}
</script>
</body>
</html>
Slideshow Indicators
An example of using buttons to indicate how many slides there are in the
slideshow, and which slide the user is currently viewing.
Prev Next
123
Example
<div class="w3-center">
<button class="w3-btn" onclick="plusDivs(-1)">❮
Prev</button>
<button class="w3-btn" onclick="plusDivs(1)">Next
❯</button>
<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<style>
.mySlides {display:none}
</style>
<body>
<div class="w3-container">
<h2>Slideshow Indicators</h2>
<p>An example of using buttons to indicate how many slides there are in the slideshow,
and which slide the user is currently viewing.</p>
</div>
<div class="w3-center">
<div class="w3-section">
<button class="w3-btn" onclick="plusDivs(-1)"> Prev</button>
<button class="w3-btn" onclick="plusDivs(1)">Next </button>
</div>
<button class="w3-btn demo" onclick="currentDiv(1)">1</button>
<button class="w3-btn demo" onclick="currentDiv(2)">2</button>
<button class="w3-btn demo" onclick="currentDiv(3)">3</button>
</div>
<script>
var slideIndex = 1;
showDivs(slideIndex);
function plusDivs(n) {
showDivs(slideIndex += n);
}
function currentDiv(n) {
showDivs(slideIndex = n);
}
function showDivs(n) {
var i;
var x = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("demo");
if (n > x.length) {slideIndex = 1}
if (n < 1) {slideIndex = x.length}
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" w3-red", "");
}
x[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " w3-red";
}
</script>
</body>
</html>
Another example:
Example
<div class="w3-content w3-display-container">
<img class="mySlides" src="img_nature.jpg">
<img class="mySlides" src="img_fjords.jpg">
<img class="mySlides" src="img_mountains.jpg">
<div class="w3-center w3-display-bottomleft" style="width:100%">
<div class="w3-left" onclick="plusDivs(-1)">❮</div>
<div class="w3-right" onclick="plusDivs(1)">❯</div>
<span class="w3-badge demo w3-
border" onclick="currentDiv(1)"></span>
<span class="w3-badge demo w3-
border" onclick="currentDiv(2)"></span>
<span class="w3-badge demo w3-
border" onclick="currentDiv(3)"></span>
</div>
</div>
Try It Yourself
<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<style>
.mySlides {display:none}
.w3-left, .w3-right, .w3-badge {cursor:pointer}
.w3-badge {height:13px;width:13px;padding:0}
</style>
<body>
<div class="w3-container">
<h2>Slideshow Indicators</h2>
<p>An example of using buttons to indicate how many slides there are in the
slideshow, and which slide the user is currently viewing.</p>
</div>
<script>
var slideIndex = 1;
showDivs(slideIndex);
function plusDivs(n) {
showDivs(slideIndex += n);
}
function currentDiv(n) {
showDivs(slideIndex = n);
}
function showDivs(n) {
var i;
var x = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("demo");
if (n > x.length) {slideIndex = 1}
if (n < 1) {slideIndex = x.length}
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" w3-white", "");
}
x[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " w3-white";
}
</script>
</body>
</html>
Images as Indicators
An example of using images as indicators:
Example
<div class="w3-content" style="max-width:1200px">
<img class="mySlides" src="img_nature_wide.jpg" style="width:100%"
>
<img class="mySlides" src="img_fjords_wide.jpg" style="width:100%"
>
<img class="mySlides" src="img_mountains_wide.jpg" style="width:10
0%">
Try It Yourself
<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<style>
.mySlides {display:none}
</style>
<body>
<div class="w3-container">
<h2>Slideshow Indicators</h2>
<p>An example of using images to indicate how many slides there are in the
slideshow, and which image the user is currently viewing (red border).</p>
</div>
<script>
var slideIndex = 1;
showDivs(slideIndex);
function plusDivs(n) {
showDivs(slideIndex += n);
}
function currentDiv(n) {
showDivs(slideIndex = n);
}
function showDivs(n) {
var i;
var x = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("demo");
if (n > x.length) {slideIndex = 1}
if (n < 1) {slideIndex = x.length}
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" w3-border-red", "");
}
x[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " w3-border-red";
}
</script>
</body>
</html>
Animated Slides
Slide or fade in an element from the top, bottom, left or right of the screen
with the w3-animate-* classes.
Example
<img class="mySlides w3-animate-top" src="img_01.jpg">
<img class="mySlides w3-animate-bottom" src="img_02.jpg">
<img class="mySlides w3-animate-top" src="img_03.jpg">
<img class="mySlides w3-animate-bottom" src="img_04.jpg">
Try It Yourself
<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<style>
.mySlides {display:none;}
</style>
<body>
<div class="w3-container">
<h2>Animated Slides</h2>
<p>Slide or fade in an element from the top, bottom, left or right of the
screen with the w3-animate-* classes.</p>
</div>
<div class="w3-content w3-section" style="max-width:500px">
</div>
<script>
var myIndex = 0;
carousel();
function carousel() {
var i;
var x = document.getElementsByClassName("mySlides");
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
myIndex++;
if (myIndex > x.length) {myIndex = 1}
x[myIndex-1].style.display = "block";
setTimeout(carousel, 2500);
}
</script>
</body>
</html>
Faded Animation
The w3-animate-fading class fades an element in and out (takes about
10 seconds).
Example
<img class="mySlides w3-animate-fading" src="img_01.jpg">
<img class="mySlides w3-animate-fading" src="img_02.jpg">
<img class="mySlides w3-animate-fading" src="img_03.jpg">
<img class="mySlides w3-animate-fading" src="img_04.jpg">
Try It Yourself
<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<body>
<div class="w3-content w3-section" style="max-width:500px">
<p>The w3-animate-fading class animates an element in and out (takes about
10 seconds).</p>
</div>
<script>
var myIndex = 0;
carousel();
function carousel() {
var i;
var x = document.getElementsByClassName("mySlides");
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
myIndex++;
if (myIndex > x.length) {myIndex = 1}
x[myIndex-1].style.display = "block";
setTimeout(carousel, 9000);
}
</script>
</body>
</html>
Templates
<!DOCTYPE html>
<html>
<title>W3.CSS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3-theme-
black.css">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-
awesome/4.6.3/css/font-awesome.min.css">
<body id="myPage">
<div class="w3-row"><br>
<div class="w3-quarter">
<img src="img_avatar.jpg" alt="Boss" style="width:45%" class="w3-circle
w3-hover-opacity">
<h3>Johnny Walker</h3>
<p>Web Designer</p>
</div>
<div class="w3-quarter">
<img src="img_avatar.jpg" alt="Boss" style="width:45%" class="w3-circle
w3-hover-opacity">
<h3>Rebecca Flex</h3>
<p>Support</p>
</div>
<div class="w3-quarter">
<img src="img_avatar.jpg" alt="Boss" style="width:45%" class="w3-circle
w3-hover-opacity">
<h3>Jan Ringo</h3>
<p>Boss man</p>
</div>
<div class="w3-quarter">
<img src="img_avatar.jpg" alt="Boss" style="width:45%" class="w3-circle
w3-hover-opacity">
<h3>Kai Ringo</h3>
<p>Fixer</p>
</div>
</div>
</div>
<div class="w3-quarter">
<h2>Our Portfolio</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum
dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident,
sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<div class="w3-quarter">
<div class="w3-card-2 w3-white">
<img src="img_fjords.jpg" alt="Vernazza" style="width:100%">
<div class="w3-container">
<h3>Customer 1</h3>
<h4>Trade</h4>
<p>Blablabla</p>
<p>Blablabla</p>
<p>Blablabla</p>
<p>Blablabla</p>
</div>
</div>
</div>
<div class="w3-quarter">
<div class="w3-card-2 w3-white">
<img src="img_lights.jpg" alt="Cinque Terre" style="width:100%">
<div class="w3-container">
<h3>Customer 2</h3>
<h4>Trade</h4>
<p>Blablabla</p>
<p>Blablabla</p>
<p>Blablabla</p>
<p>Blablabla</p>
</div>
</div>
</div>
<div class="w3-quarter">
<div class="w3-card-2 w3-white">
<img src="img_mountains.jpg" alt="Monterosso" style="width:100%">
<div class="w3-container">
<h3>Customer 3</h3>
<h4>Trade</h4>
<p>Blablabla</p>
<p>Blablabla</p>
<p>Blablabla</p>
<p>Blablabla</p>
</div>
</div>
</div>
</div>
function initialize() {
var mapProp = {
center: myCenter,
zoom: 5,
scrollwheel: false,
draggable: false,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
marker.setMap(map);
}
</body>
</html>
<!DOCTYPE html>
<html>
<title>W3.CSS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?
family=Raleway">
<style>
body,h1,h2,h3,h4,h5 {font-family: "Raleway", sans-serif}
</style>
<body class="w3-light-grey">
<div class="w3-container">
<p>Mauris neque quam, fermentum ut nisl vitae, convallis maximus nisl.
Sed mattis nunc id lorem euismod placerat. Vivamus porttitor magna enim, ac
accumsan tortor cursus at. Phasellus sed ultricies mi non congue ullam corper.
Praesent tincidunt sed
tellus ut rutrum. Sed vitae justo condimentum, porta lectus vitae, ultricies
congue gravida diam non fringilla.</p>
<div class="w3-row">
<div class="w3-col m8 s12">
<p><button class="w3-btn w3-padding-large w3-white w3-border w3-
hover-border-black"><b>READ MORE </b></button></p>
</div>
<div class="w3-col m4 w3-hide-small">
<p><span class="w3-padding-large w3-right"><b>Comments </b>
<span class="w3-tag">0</span></span></p>
</div>
</div>
</div>
</div>
<hr>
<div class="w3-container">
<p>Mauris neque quam, fermentum ut nisl vitae, convallis maximus nisl.
Sed mattis nunc id lorem euismod placerat. Vivamus porttitor magna enim, ac
accumsan tortor cursus at. Phasellus sed ultricies mi non congue ullam corper.
Praesent tincidunt sed
tellus ut rutrum. Sed vitae justo condimentum, porta lectus vitae, ultricies
congue gravida diam non fringilla.</p>
<div class="w3-row">
<div class="w3-col m8 s12">
<p><button class="w3-btn w3-padding-large w3-white w3-border w3-
hover-border-black"><b>READ MORE </b></button></p>
</div>
<div class="w3-col m4 w3-hide-small">
<p><span class="w3-padding-large w3-right"><b>Comments </b>
<span class="w3-badge">2</span></span></p>
</div>
</div>
</div>
</div>
<!-- END BLOG ENTRIES -->
</div>
<!-- Introduction menu -->
<div class="w3-col l4 w3-hide-medium w3-hide-small">
<!-- About Card -->
<div class="w3-card-2 w3-margin w3-margin-top">
<img src="img_avatar_g.jpg" style="width:100%">
<div class="w3-container w3-white">
<h4><b>My Name</b></h4>
<p>Just me, myself and I, exploring the universe of uknownment. I have a
heart of love and a interest of lorem ipsum and mauris neque quam blog. I
want to share my world with you.</p>
</div>
</div><hr>
</body>
</html>
<!DOCTYPE html>
<html>
<title>W3.CSS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?
family=Montserrat">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-
awesome/4.6.3/css/font-awesome.min.css">
<style>
body,h1 {font-family: "Montserrat", sans-serif; font-weight: bold}
img {margin-bottom: -7px}
.w3-row-padding img {margin-bottom: 12px}
</style>
<body>
<div class="w3-third">
<img src="img_coffee.jpg" style="width:100%">
<img src="img_bridge.jpg" style="width:100%">
<img src="img_notebook.jpg" style="width:100%">
<img src="img_london.jpg" style="width:100%">
<img src="img_rocks.jpg" style="width:100%">
<img src="img_avatar_g.jpg" style="width:100%">
</div>
<div class="w3-third">
<img src="img_mist.jpg" style="width:100%">
<img src="img_workbench.jpg" style="width:100%">
<img src="img_gondol.jpg" style="width:100%">
<img src="img_skies.jpg" style="width:100%">
<img src="img_lights.jpg" style="width:100%">
<img src="img_workshop.jpg" style="width:100%">
</div>
</div>
</div>
<!-- Clear floats -->
<div class="w3-clear"></div><br><br>
<script>
// Toggle grid padding
function myFunction() {
var x = document.getElementById("myGrid");
if (x.className.indexOf("w3-row-padding") == -1) {
x.className += " w3-row-padding";
} else {
x.className = x.className.replace(" w3-row-padding", "");
}
}
function w3_close() {
document.getElementById("mySidenav").style.display = "none";
}
</script>
</body>
</html>
Start
<!DOCTYPE html>
<html>
<title>W3.CSS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?
family=Montserrat">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-
awesome/4.6.3/css/font-awesome.min.css">
<style>
body,h1,h2,h3,h4,h5,h6 {font-family: "Lato", sans-serif}
.w3-navbar,h1,button {font-family: "Montserrat", sans-serif}
.fa-anchor,.fa-coffee {font-size:200px}
</style>
<body>
<div class="w3-twothird">
<h1>Lorem Ipsum</h1>
<h5 class="w3-padding-32">Lorem ipsum dolor sit amet, consectetur
adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi
ut aliquip ex ea commodo consequat.</h5>
<script>
// Used to toggle the menu on small screens when clicking on the menu button
function myFunction() {
var x = document.getElementById("navDemo");
if (x.className.indexOf("w3-show") == -1) {
x.className += " w3-show";
} else {
x.className = x.className.replace(" w3-show", "");
}
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<title>W3.CSS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?
family=Raleway">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-
awesome/4.6.3/css/font-awesome.min.css">
<style>
html,body,h1,h2,h3,h4,h5 {font-family: "Raleway", sans-serif}
.w3-sidenav a,.w3-sidenav h4 {font-weight:bold}
</style>
<body class="w3-light-grey w3-content" style="max-width:1600px">
<!-- Sidenav/menu -->
<nav class="w3-sidenav w3-collapse w3-white w3-animate-left" style="z-
index:3;width:300px;" id="mySidenav"><br>
<div class="w3-container">
<a href="#" onclick="w3_close()" class="w3-hide-large w3-right w3-jumbo
w3-padding" title="close menu">
<i class="fa fa-remove"></i>
</a>
<img src="img_avatar_g2.jpg" style="width:45%;" class="w3-
round"><br><br>
<h4 class="w3-padding-0"><b>PORTFOLIO</b></h4>
<p class="w3-text-grey">Template by W3.CSS</p>
</div>
<a href="#" class="w3-padding w3-text-teal">HOME</a>
<a href="#" class="w3-padding">ABOUT</a>
<a href="#" class="w3-padding">PORTFOLIO</a>
<a href="#" class="w3-padding">SHOP</a>
<a href="#" class="w3-padding">CONTACT</a>
<div class="w3-third">
<h3>BLOG POSTS</h3>
<ul class="w3-ul w3-hoverable">
<li class="w3-padding-16">
<img src="img_workshop.jpg" class="w3-left w3-margin-right"
style="width:50px">
<span class="w3-large">Lorem</span><br>
<span>Sed mattis nunc</span>
</li>
<li class="w3-padding-16">
<img src="img_gondol.jpg" class="w3-left w3-margin-right"
style="width:50px">
<span class="w3-large">Ipsum</span><br>
<span>Praes tinci sed</span>
</li>
</ul>
</div>
<div class="w3-third">
<h3>POPULAR TAGS</h3>
<p>
<span class="w3-tag w3-black w3-margin-bottom">Travel</span> <span
class="w3-tag w3-dark-grey w3-small w3-margin-bottom">New York</span>
<span class="w3-tag w3-dark-grey w3-small w3-margin-
bottom">London</span>
<span class="w3-tag w3-dark-grey w3-small w3-margin-
bottom">IKEA</span> <span class="w3-tag w3-dark-grey w3-small w3-
margin-bottom">NORWAY</span> <span class="w3-tag w3-dark-grey w3-
small w3-margin-bottom">DIY</span>
<span class="w3-tag w3-dark-grey w3-small w3-margin-
bottom">Ideas</span> <span class="w3-tag w3-dark-grey w3-small w3-
margin-bottom">Baby</span> <span class="w3-tag w3-dark-grey w3-small
w3-margin-bottom">Family</span>
<span class="w3-tag w3-dark-grey w3-small w3-margin-
bottom">News</span> <span class="w3-tag w3-dark-grey w3-small w3-
margin-bottom">Clothing</span> <span class="w3-tag w3-dark-grey w3-
small w3-margin-bottom">Shopping</span>
<span class="w3-tag w3-dark-grey w3-small w3-margin-
bottom">Sports</span> <span class="w3-tag w3-dark-grey w3-small w3-
margin-bottom">Games</span>
</p>
</div>
</div>
</footer>
<script>
// Script to open and close sidenav
function w3_open() {
document.getElementById("mySidenav").style.display = "block";
document.getElementById("myOverlay").style.display = "block";
}
function w3_close() {
document.getElementById("mySidenav").style.display = "none";
document.getElementById("myOverlay").style.display = "none";
}
</script>
</body>
</html>
Js data3
/* W3Data ver 1.1 by W3Schools.com */
var w3DataObject = {};
function w3DisplayData(id, data) {
var htmlObj, htmlTemplate, html, arr = [], a, l, rowClone, x, j, i,
ii, cc, repeat, repeatObj, repeatX = "";
htmlObj = document.getElementById(id);
htmlTemplate = w3InitTemplate(id, htmlObj);
html = htmlTemplate.cloneNode(true);
arr = w3GetElementsByAttribute(html, "w3-repeat");
l = arr.length;
for (j = (l-1); j >= 0; j -= 1) {
cc = arr[j].getAttribute("w3-repeat").split(" ");
if (cc.length == 1) {
repeat = cc[0];
} else {
repeatX = cc[0];
repeat = cc[2];
}
arr[j].removeAttribute("w3-repeat");
repeatObj = data[repeat];
if (repeatObj && typeof repeatObj == "object" && repeatObj.length
!= "undefined") {
i = 0;
for (x in repeatObj) {
i += 1;
rowClone = arr[j];
rowClone = w3NeedleInHaystack(rowClone, "element",
repeatX, repeatObj[x]);
a = rowClone.attributes;
for (ii = 0; ii < a.length; ii += 1) {
a[ii].value = w3NeedleInHaystack(a[ii], "attribute",
repeatX, repeatObj[x]).value;
}
(i === repeatObj.length) ?
arr[j].parentNode.replaceChild(rowClone, arr[j]) :
arr[j].parentNode.insertBefore(rowClone, arr[j]);
}
} else {
console.log("w3-repeat must be an array. " + repeat + " is
not an array.");
continue;
}
}
html = w3NeedleInHaystack(html, "element");
htmlObj.parentNode.replaceChild(html, htmlObj);
function w3InitTemplate(id, obj) {
var template;
template = obj.cloneNode(true);
if (w3DataObject.hasOwnProperty(id)) {return w3DataObject[id];}
w3DataObject[id] = template;
return template;
}
function w3GetElementsByAttribute(x, att) {
var arr = [], arrCount = -1, i, l, y =
x.getElementsByTagName("*"), z = att.toUpperCase();
l = y.length;
for (i = -1; i < l; i += 1) {
if (i == -1) {y[i] = x; }
if (y[i].getAttribute(z) !== null) {arrCount += 1;
arr[arrCount] = y[i];}
}
return arr;
}
function w3NeedleInHaystack(elmnt, typ, repeatX, x) {
var value, rowClone, pos1, haystack, pos2, needle = [],
needleToReplace, i, cc, r;
rowClone = elmnt.cloneNode(true);
pos1 = 0;
while (pos1 > -1) {
haystack = (typ == "attribute") ? rowClone.value :
rowClone.innerHTML;
pos1 = haystack.indexOf("{{", pos1);
if (pos1 === -1) {break; }
pos2 = haystack.indexOf("}}", pos1 + 1);
needleToReplace = haystack.substring(pos1 + 2, pos2);
needle = needleToReplace.split("||");
value = undefined;
for (i = 0; i < needle.length; i += 1) {
needle[i] = needle[i].replace(/^\s+|\s+$/gm,''); //trim
//value = ((x && x[needle[i]]) || (data &&
data[needle[i]]));
if (x) {value = x[needle[i]];}
if (value == undefined && data) {value =
data[needle[i]];}
if (value == undefined) {
cc = needle[i].split(".");
if (cc[0] == repeatX) {value = x[cc[1]]; }
}
if (value == undefined) {
if (needle[i] == repeatX) {value = x; }
}
if (value == undefined) {
if (needle[i].substr(0,1) == '"') {
value = needle[i].replace(/"/g, "");
} else if (needle[i].substr(0,1) == "'") {
value = needle[i].replace(/'/g, "");
}
}
if (value != undefined) {break;}
}
if (value != undefined) {
r = "{{" + needleToReplace + "}}";
if (typ == "attribute") {
rowClone.value = rowClone.value.replace(r, value);
} else {
w3ReplaceHTML(rowClone, r, value);
}
}
pos1 = pos1 + 1;
}
return rowClone;
}
function w3ReplaceHTML(a, r, result) {
var b, l, i, a, x, y, j, ll, nam;
if (a.hasAttributes()) {
b = a.attributes;
l = b.length;
for (i = 0; i < l; i += 1) {
if (b[i].value.indexOf(r) > -1) {b[i].value =
b[i].value.replace(r, result); }
}
}
x = a.getElementsByTagName("*");
l = x.length;
a.innerHTML = a.innerHTML.replace(r, result);
}
}
function w3IncludeHTML() {
var z, i, a, file, xhttp;
z = document.getElementsByTagName("*");
for (i = 0; i < z.length; i++) {
if (z[i].getAttribute("w3-include-html")) {
a = z[i].cloneNode(false);
file = z[i].getAttribute("w3-include-html");
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
a.removeAttribute("w3-include-html");
a.innerHTML = xhttp.responseText;
z[i].parentNode.replaceChild(a, z[i]);
w3IncludeHTML();
}
}
xhttp.open("GET", file, true);
xhttp.send();
return;
}
}
}
function w3Http(target, readyfunc, xml, method) {
var httpObj;
if (!method) {method = "GET"; }
if (window.XMLHttpRequest) {
httpObj = new XMLHttpRequest();
} else if (window.ActiveXObject) {
httpObj = new ActiveXObject("Microsoft.XMLHTTP");
}
if (httpObj) {
if (readyfunc) {httpObj.onreadystatechange = readyfunc; }
httpObj.open(method, target, true);
httpObj.send(xml);
}
}
<!DOCTYPE html>
<html>
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<script src="http://www.w3schools.com/lib/w3data.js"></script>
<script>
var myObject = {"customers":[
{"CustomerName":"Alfreds Futterkiste","City":"Berlin","Country":"Germany"},
{"CustomerName":"Ana Trujillo Emparedados y helados","City":"Mxico
D.F.","Country":"Mexico"},
{"CustomerName":"Antonio Moreno Taquera","City":"Mxico
D.F.","Country":"Mexico"},
{"CustomerName":"Around the Horn","City":"London","Country":"UK"},
{"CustomerName":"B's Beverages","City":"London","Country":"UK"},
{"CustomerName":"Berglunds snabbkp","City":"Lule","Country":"Sweden"},
{"CustomerName":"Blauer See
Delikatessen","City":"Mannheim","Country":"Germany"},
{"CustomerName":"Blondel pre et
fils","City":"Strasbourg","Country":"France"},
{"CustomerName":"Blido Comidas
preparadas","City":"Madrid","Country":"Spain"},
{"CustomerName":"Bon app'","City":"Marseille","Country":"France"},
{"CustomerName":"Bottom-Dollar
Marketse","City":"Tsawassen","Country":"Canada"},
{"CustomerName":"Cactus Comidas para llevar","City":"Buenos
Aires","Country":"Argentina"},
{"CustomerName":"Centro comercial Moctezuma","City":"Mxico
D.F.","Country":"Mexico"},
{"CustomerName":"Chop-suey
Chinese","City":"Bern","Country":"Switzerland"},
{"CustomerName":"Comrcio Mineiro","City":"So Paulo","Country":"Brazil"}
]};
</script>
<body>
</body>
</html>