是否可以使用对象将函数的结果赋给PHP变量?

时间:2019-06-29 20:29:06

标签: javascript-objects

我正在尝试获取有关鼠标移动的信息。我在这里找到了一个有效的代码:github.com/ajlkn/jquery.touch。

我正在使用带有该脚本的html文档,该文档显示了我需要的有关鼠标移动的信息。 但是我需要将该信息分配给PHP代码的变量,但我并没有成功理解该怎么做。

var Pad = {
    padElem : null,
    elems: null,

    init: function() {
        Pad.padElem = $("#pad");

        Pad.padElem.find(".pad-elem").bind("mousedown touchstart", function(event) {
            Pad.id = $(event.target).parent().attr("id")
        })

        Pad.padElem
            .touch({
                trackDocument: true,
                trackDocumentNormalize: true,
                preventDefault: {
                    drag: true,
                    swipe: true
                }
            })
            .on('swipeLeft', function(e, o) {
                _output('Left - Dist: ' + Math.round(o.distance) + ', Dur: ' + o.duration + ', V: ' + Math.round(o.velocity)+', ID: ' + Pad.id);
                Pad.id = null;
            })
            .on('swipeRight', function(e, o) {
                _output('Right - Dist: ' + Math.round(o.distance) + ', Dur: ' + o.duration + ', V: ' + Math.round(o.velocity)+', ID: ' + Pad.id);
                Pad.id = null;
            });
    },
};

function _output(s) {
    $("#output").html(s);
}


在此先感谢可以帮助我的人。

0 个答案:

没有答案
相关问题