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) + "]")
                    }
                })
            })

  • 相关阅读:
    图算法之广度优先遍历
    图形算法之深度优先遍历
    list下SORT排序方法使用
    Linux使用curl进行接口测试
    Template方法应用
    profile[计算方法耗时模块]用法
    性能测试的实施及总结(二)
    yum源配置
    Dockerfile文件
    Docker的Image与Container
  • 原文地址:https://www.cnblogs.com/beyond-f/p/9507471.html
Copyright © 2011-2022 走看看