Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery.resize-won';不可触发_Jquery_Events_Triggers_Resize - Fatal编程技术网

Jquery.resize-won';不可触发

Jquery.resize-won';不可触发,jquery,events,triggers,resize,Jquery,Events,Triggers,Resize,在执行以下操作后,我尝试了以下操作以触发调整大小事件: $(window).ready(function(){ $(window).resize(function(){ if($(".formEvent").length){ // If element exist addEventForm($("span.active")); // resize process } }); c

在执行以下操作后,我尝试了以下操作以触发调整大小事件:

$(window).ready(function(){
    $(window).resize(function(){
        if($(".formEvent").length){ // If element exist
            addEventForm($("span.active")); // resize process
        }
    });
    console.log($(window).data("events"));
});
为什么他不会触发我的事件

编辑:addEventForm可以工作,因为当单击时,他会及时被触发来创建我的元素

编辑2: 以下是addEventform函数:

function addEventForm(jour){
    if(!$(".formEvent").length){
        jour.closest("tr").after("<form class='formEvent'><div class='curseur'></div></form>");
    }
    
    var percent = jour.offset().left-jour.closest("tr").offset().left+parseInt(jour.css("margin-left").replace("px", ""))+ parseInt(jour.css("padding-left").replace("px", ""))+parseInt(jour.css("border-left-width").replace("px", ""));
    $(".formEvent .curseur").css({"top" : "-15px" , "left": percent+"px"});
    $(".formEvent").show()
}
函数加法格式(jour){
如果(!$(“.formEvent”).length){
日最接近(“tr”)。在(“”)之后;
}
var percent=jour.offset().left jour.closest(“tr”).offset().left+parseInt(jour.css(“margin left”).replace(“px”,“左边距”)+parseInt(jour.css(“padding left”).replace(“px”,“左边距”)+parseInt(jour.css(“border left width”).replace”(“px”,“左边距”));
$(.formEvent.curseur”).css({“top”:“-15px”,“left”:percent+“px”});
$(“.formEvent”).show()
}

我试图在resize函数中放入一个控制台日志,并按预期启动它

$(window).ready(function(){
    $(window).resize(function(){
        console.log('check');
        if($(".formEvent").length){ // If element exist
            addEventForm($("span.active")); // resize process
        }
    });
    console.log($(window).data("events"));
});


if语句中一定有东西坏了。

我试图在resize函数中放入一个控制台日志,并按预期触发它

$(window).ready(function(){
    $(window).resize(function(){
        console.log('check');
        if($(".formEvent").length){ // If element exist
            addEventForm($("span.active")); // resize process
        }
    });
    console.log($(window).data("events"));
});


你的if语句中肯定有东西坏了。

我纠正了我的错误。它真的很模糊

window.onresize = function(){
    if($(".formEvent").length){
        addEventForm($("span.active"));
    }
};

使用JavaScriptAPI,一切正常。所以让我们保留这个。

我修正了我的正确答案。它真的很模糊

window.onresize = function(){
    if($(".formEvent").length){
        addEventForm($("span.active"));
    }
};

使用JavaScriptAPI,一切正常。所以让我们保留这个。

您的代码看起来很好。您如何确定事件未被触发?您确定代码中没有错误吗?你检查控制台了吗?我检查了控制台,没有错误,但是对于$(窗口)的console.log,我没有定义。你在窗口上定义了任何
数据
属性了吗?您的代码没有显示任何no,但正如我所读到的,当我们有一个事件侦听器时,它将像sohu导入jQuery一样被添加?您的代码看起来很好。您如何确定事件未被触发?您确定代码中没有错误吗?你检查控制台了吗?我检查了控制台,没有错误,但是对于$(窗口)的console.log,我没有定义。你在窗口上定义了任何
数据
属性了吗?您的代码没有显示任何否,但正如我所读到的,当我们有一个事件侦听器时,它将像Sohu导入的jQuery一样被添加?嗯,是的,正如我所看到的。我会编辑这篇文章,向你展示我的addEventForm函数。将编辑帖子,向您展示我的addEventForm函数