how to create image gallery with next/previous buttons?
up vote
-1
down vote
favorite
I made a image gallery and added next/previous buttons to this gallery. When click on the image, The gallery is open.So, I tried combine it with other galleries but nothing worked properly. How can I implement below code. This is working (Plunker)
$(document).ready(function()
$.ajax(
type:"GET",
url:"data.xml",
dataType:"xml",
success:xmlParser2
);
);
function xmlParser2(xml)
xml = $(xml).children();
let i = 0;
let total = $(xml).children().length;
$(xml).children().each(function (idx,index,item)
let tag = $(this).prop("tagName");
let nextIdx = idx + 1;
let prevIdx = idx - 1;
//to make cyclic
nextIdx = nextIdx == total ? 0 : nextIdx;
prevIdx = prevIdx == -1 ? (total -1) : prevIdx;
let image = '<img style="background-image:url(' + $(this).find("image").text() + ')"' + '" />';
let image2 = '<div><img src="' + $(this).find("image").text() + '" width="100%" alt="' + '" />' + '</div>';
let head = '<div>' + $(this).find("head").text() + '</div>';
let html = `<div class="col-sm-4 random reveal" id="random">
<div class="thumbnail randomdiv3">
<a href="#$tag + idx" id="openModalBtn">
<div>$image</div>
<h5>$head</h5>
</a>
</div>
</div>`;
let popup = `<div id="$tag + idx" class="overlay">
<div class="popup">
<a href="#$tag + prevIdx" class="previous round">‹</a>
<a href="#$tag + nextIdx" class="next round">›</a>
<h6>$head</h6>
<a class="close" href="#">×</a>
<div>$image2</div>
</div>
</div>`;
$("#xmldata").append(html);
$("#popup").append(popup);
);
javascript jquery html xml
add a comment |
up vote
-1
down vote
favorite
I made a image gallery and added next/previous buttons to this gallery. When click on the image, The gallery is open.So, I tried combine it with other galleries but nothing worked properly. How can I implement below code. This is working (Plunker)
$(document).ready(function()
$.ajax(
type:"GET",
url:"data.xml",
dataType:"xml",
success:xmlParser2
);
);
function xmlParser2(xml)
xml = $(xml).children();
let i = 0;
let total = $(xml).children().length;
$(xml).children().each(function (idx,index,item)
let tag = $(this).prop("tagName");
let nextIdx = idx + 1;
let prevIdx = idx - 1;
//to make cyclic
nextIdx = nextIdx == total ? 0 : nextIdx;
prevIdx = prevIdx == -1 ? (total -1) : prevIdx;
let image = '<img style="background-image:url(' + $(this).find("image").text() + ')"' + '" />';
let image2 = '<div><img src="' + $(this).find("image").text() + '" width="100%" alt="' + '" />' + '</div>';
let head = '<div>' + $(this).find("head").text() + '</div>';
let html = `<div class="col-sm-4 random reveal" id="random">
<div class="thumbnail randomdiv3">
<a href="#$tag + idx" id="openModalBtn">
<div>$image</div>
<h5>$head</h5>
</a>
</div>
</div>`;
let popup = `<div id="$tag + idx" class="overlay">
<div class="popup">
<a href="#$tag + prevIdx" class="previous round">‹</a>
<a href="#$tag + nextIdx" class="next round">›</a>
<h6>$head</h6>
<a class="close" href="#">×</a>
<div>$image2</div>
</div>
</div>`;
$("#xmldata").append(html);
$("#popup").append(popup);
);
javascript jquery html xml
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I made a image gallery and added next/previous buttons to this gallery. When click on the image, The gallery is open.So, I tried combine it with other galleries but nothing worked properly. How can I implement below code. This is working (Plunker)
$(document).ready(function()
$.ajax(
type:"GET",
url:"data.xml",
dataType:"xml",
success:xmlParser2
);
);
function xmlParser2(xml)
xml = $(xml).children();
let i = 0;
let total = $(xml).children().length;
$(xml).children().each(function (idx,index,item)
let tag = $(this).prop("tagName");
let nextIdx = idx + 1;
let prevIdx = idx - 1;
//to make cyclic
nextIdx = nextIdx == total ? 0 : nextIdx;
prevIdx = prevIdx == -1 ? (total -1) : prevIdx;
let image = '<img style="background-image:url(' + $(this).find("image").text() + ')"' + '" />';
let image2 = '<div><img src="' + $(this).find("image").text() + '" width="100%" alt="' + '" />' + '</div>';
let head = '<div>' + $(this).find("head").text() + '</div>';
let html = `<div class="col-sm-4 random reveal" id="random">
<div class="thumbnail randomdiv3">
<a href="#$tag + idx" id="openModalBtn">
<div>$image</div>
<h5>$head</h5>
</a>
</div>
</div>`;
let popup = `<div id="$tag + idx" class="overlay">
<div class="popup">
<a href="#$tag + prevIdx" class="previous round">‹</a>
<a href="#$tag + nextIdx" class="next round">›</a>
<h6>$head</h6>
<a class="close" href="#">×</a>
<div>$image2</div>
</div>
</div>`;
$("#xmldata").append(html);
$("#popup").append(popup);
);
javascript jquery html xml
I made a image gallery and added next/previous buttons to this gallery. When click on the image, The gallery is open.So, I tried combine it with other galleries but nothing worked properly. How can I implement below code. This is working (Plunker)
$(document).ready(function()
$.ajax(
type:"GET",
url:"data.xml",
dataType:"xml",
success:xmlParser2
);
);
function xmlParser2(xml)
xml = $(xml).children();
let i = 0;
let total = $(xml).children().length;
$(xml).children().each(function (idx,index,item)
let tag = $(this).prop("tagName");
let nextIdx = idx + 1;
let prevIdx = idx - 1;
//to make cyclic
nextIdx = nextIdx == total ? 0 : nextIdx;
prevIdx = prevIdx == -1 ? (total -1) : prevIdx;
let image = '<img style="background-image:url(' + $(this).find("image").text() + ')"' + '" />';
let image2 = '<div><img src="' + $(this).find("image").text() + '" width="100%" alt="' + '" />' + '</div>';
let head = '<div>' + $(this).find("head").text() + '</div>';
let html = `<div class="col-sm-4 random reveal" id="random">
<div class="thumbnail randomdiv3">
<a href="#$tag + idx" id="openModalBtn">
<div>$image</div>
<h5>$head</h5>
</a>
</div>
</div>`;
let popup = `<div id="$tag + idx" class="overlay">
<div class="popup">
<a href="#$tag + prevIdx" class="previous round">‹</a>
<a href="#$tag + nextIdx" class="next round">›</a>
<h6>$head</h6>
<a class="close" href="#">×</a>
<div>$image2</div>
</div>
</div>`;
$("#xmldata").append(html);
$("#popup").append(popup);
);
$(document).ready(function()
$.ajax(
type:"GET",
url:"data.xml",
dataType:"xml",
success:xmlParser2
);
);
function xmlParser2(xml)
xml = $(xml).children();
let i = 0;
let total = $(xml).children().length;
$(xml).children().each(function (idx,index,item)
let tag = $(this).prop("tagName");
let nextIdx = idx + 1;
let prevIdx = idx - 1;
//to make cyclic
nextIdx = nextIdx == total ? 0 : nextIdx;
prevIdx = prevIdx == -1 ? (total -1) : prevIdx;
let image = '<img style="background-image:url(' + $(this).find("image").text() + ')"' + '" />';
let image2 = '<div><img src="' + $(this).find("image").text() + '" width="100%" alt="' + '" />' + '</div>';
let head = '<div>' + $(this).find("head").text() + '</div>';
let html = `<div class="col-sm-4 random reveal" id="random">
<div class="thumbnail randomdiv3">
<a href="#$tag + idx" id="openModalBtn">
<div>$image</div>
<h5>$head</h5>
</a>
</div>
</div>`;
let popup = `<div id="$tag + idx" class="overlay">
<div class="popup">
<a href="#$tag + prevIdx" class="previous round">‹</a>
<a href="#$tag + nextIdx" class="next round">›</a>
<h6>$head</h6>
<a class="close" href="#">×</a>
<div>$image2</div>
</div>
</div>`;
$("#xmldata").append(html);
$("#popup").append(popup);
);
$(document).ready(function()
$.ajax(
type:"GET",
url:"data.xml",
dataType:"xml",
success:xmlParser2
);
);
function xmlParser2(xml)
xml = $(xml).children();
let i = 0;
let total = $(xml).children().length;
$(xml).children().each(function (idx,index,item)
let tag = $(this).prop("tagName");
let nextIdx = idx + 1;
let prevIdx = idx - 1;
//to make cyclic
nextIdx = nextIdx == total ? 0 : nextIdx;
prevIdx = prevIdx == -1 ? (total -1) : prevIdx;
let image = '<img style="background-image:url(' + $(this).find("image").text() + ')"' + '" />';
let image2 = '<div><img src="' + $(this).find("image").text() + '" width="100%" alt="' + '" />' + '</div>';
let head = '<div>' + $(this).find("head").text() + '</div>';
let html = `<div class="col-sm-4 random reveal" id="random">
<div class="thumbnail randomdiv3">
<a href="#$tag + idx" id="openModalBtn">
<div>$image</div>
<h5>$head</h5>
</a>
</div>
</div>`;
let popup = `<div id="$tag + idx" class="overlay">
<div class="popup">
<a href="#$tag + prevIdx" class="previous round">‹</a>
<a href="#$tag + nextIdx" class="next round">›</a>
<h6>$head</h6>
<a class="close" href="#">×</a>
<div>$image2</div>
</div>
</div>`;
$("#xmldata").append(html);
$("#popup").append(popup);
);
javascript jquery html xml
javascript jquery html xml
asked yesterday
Saji
166
166
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53224489%2fhow-to-create-image-gallery-with-next-previous-buttons%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password