有谁知道如何在移动设备上制作以下代码?我目前使用的方法可以在ohessbert.com/mobile/story.htm
找到<script>
var links = document.querySelectorAll(".heart");
var wrapper = document.querySelector("#wrapper");
var activeLink = 0;
for (var i = 0; i < links.length; i++) {
var link = links[i];
link.addEventListener('click', setClickedItem, false);
link.itemID = i;
}
links[activeLink].classList.add("active");
function setClickedItem(e) {
removeActiveLinks();
var clickedLink = e.target;
activeLink = clickedLink.itemID;
changePosition(clickedLink);
}
function removeActiveLinks() {
for (var i = 0; i < links.length; i++) {
links[i].classList.remove("active");
}
}
function changePosition(link) {
link.classList.add("active");
var position = link.getAttribute("data-pos");
wrapper.style.left = position;
}
</script>
答案 0 :(得分:-1)
您可以在代码中使用Swiper API。它在移动设备中运行良好。 http://www.idangero.us/swiper/api/#.VXHjE0Zs5jQ