这是我上一个问题的后续问题(控制组:JQuery Mobile 上有 3 个水平按钮、多行 https://stackoverflow.com/questions/26088729/controlgroup-3-buttons-horizontal-multiple-rows-on-jquery-mobile)这个问题得到了很好的回答。
我现在有多个垂直“控件”,每个控件由 4 个带有水平图像的链接组成。
其中一幅图像是向下移动。当按下此图像按钮/链接时,4 个链接的整个控件应向下移动 1。
我一直在使用追加、前置、之后、之前,但似乎没有任何效果。
我已经更新了我的Demo http://jsfiddle.net/houtq5ku/1/,它将创建 4 个控件。当按下带有向下错误的按钮时,整个块应该向下移动。
// Check if not already at the end:
if (layerVisibleButton.length > 0) {
// TODO: How to continue?
}
您将需要使用.nextAll() http://api.jquery.com/nextall/, .nextUntil() http://api.jquery.com/nextuntil/, .prevUntil() http://api.jquery.com/prevuntil/, .addBack() http://api.jquery.com/addback/, .next() http://api.jquery.com/next/, .after() http://api.jquery.com/after/, .add() http://api.jquery.com/add/ and .eq() http://api.jquery.com/eq/.
-
$(this).nextAll(".ui-last-child").eq(1)
检查当前组之后是否还有一组按钮。
-
$(this).prevUntil(".ui-last-child").addBack()
获取同一行的所有按钮down按钮和.addBack()
down按钮到 jQuery 集合对象。现在我们有三个按钮。
-
$(this).next(".ui-last-child")
下一步按钮。现在我们已经收集了四个按钮(全部),但我们仍然需要merge它们成为一个物体。
-
prevBtns.add(nextBtn)
将所有按钮合并到一个对象/变量中。
-
moveAfter.after(setBtns)
将所有按钮移动/附加到当前按钮组下方的行之后。
$("#layercontrol").on("click", ".down", function () {
var moveAfter = $(this).nextAll(".ui-last-child").eq(1);
if (moveAfter.length > 0) {
var prevBtns = $(this).prevUntil(".ui-last-child").addBack(),
nextBtn = $(this).next(".ui-last-child"),
setBtns = prevBtns.add(nextBtn);
moveAfter.after(setBtns);
}
});
Demo http://jsfiddle.net/Palestinian/w7gr54j9/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)