zoukankan      html  css  js  c++  java
  • jQuery做一个小小的移动图片的位置

    样式图点击按钮移动:

    jQuery代码如下:

            $(function () {

                //上
                $("#btnUp").click(function () {

                    var f = parseInt($("img").parent().attr("id"));
                    if (f-3 >= 1) {
                            $("img").remove().clone().appendTo("td[id="+(f-3)+"]")
                    }
                   
                })
                //下
                $("#btnDown").click(function () {
                    var f = parseInt($("img").parent().attr("id"));
                    if (f + 3 <= 9) {
                        $("img").remove().clone().appendTo("td[id=" + (f + 3) + "]")
                    }
                })
                //左
                $("#btnLeft").click(function () {

                    var f = parseInt($("img").parent().attr("id"));
                    if (f - 1 >= 1 && f % 3 != 1) {
                        $("img").remove().clone().appendTo("td[id=" + (f - 1) + "]")
                    }

                })
                //右
                $("#btnRight").click(function () {

                    var f = parseInt($("img").parent().attr("id"));
                    if (f + 1 <= 9 && f % 3 != 0) {
                        $("img").remove().clone().appendTo("td[id=" + (f + 1) + "]")
                    }
                })
            })

  • 相关阅读:
    JavaScript对象与数组大全
    矛盾后……
    信息化及信息系统课程相关网络资源
    有雪的日子..
    Gmail下蛋!!
    OS由XP换用WIN2003,问题以及解决
    软件考试
    又是生我的气..
    不得不说的无奈
    2005新年新气象..
  • 原文地址:https://www.cnblogs.com/beyond-f/p/9507471.html
Copyright © 2011-2022 走看看