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

  • 相关阅读:
    dll-IL-metadata-反射
    Linux(Ubuntu)下安装Angular2
    在nodejs中使用input file批量上传文件的方法
    jq动态添加的元素触发绑定事件无效
    简单的在线计算器
    不同方法实现按钮背景图片的变换
    unity特殊文件夹
    《暗黑战神》随堂笔记
    《打砖块》教程知识梳理
    unity零散小知识
  • 原文地址:https://www.cnblogs.com/beyond-f/p/9507471.html
Copyright © 2011-2022 走看看