Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.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 将事件绑定到动态加载的html_Jquery_Icenium - Fatal编程技术网

Jquery 将事件绑定到动态加载的html

Jquery 将事件绑定到动态加载的html,jquery,icenium,Jquery,Icenium,在通过jQuery.load加载HTML后,我尝试绑定到click/touchstart事件,如下所示: var screen = $("#somediv"); function LoadScenarioScreen(){ screen.empty(); screen.load('templates.html #ScenarioSelect',function(){ $(document).on('click touchstart','div#squishy_

在通过jQuery.load加载HTML后,我尝试绑定到click/touchstart事件,如下所示:

var screen = $("#somediv");

function LoadScenarioScreen(){
    screen.empty();

    screen.load('templates.html #ScenarioSelect',function(){
        $(document).on('click touchstart','div#squishy_box', function(e){
            alert('hello');
        });
    });
}
加载HTML效果很好,但是绑定到HTML中的元素就不行了。我正在使用jQuery1.11,并通过Icenium在模拟器和我的iPad上进行尝试。从.on函数中删除可选选择器会使单击工作正常,但在其他方面不会有任何效果

编辑:发布成堆的HTML没有意义,但加载文档的第一部分是:

<div id="ScenarioSelect">
    <div class="box">
        <div id="squishy_box" class="arrow_box">


你选对选择器了吗?加载的html中是否有ID为
squishy_box
的DIV?是的,是的,在答案中添加了一些html。呸!
.box
类被绝对定位,内部的
#squishy_box
被另一个
.box
覆盖,因为第二个box的内部位置被进一步向左移动,而不是外部的
.box'。将
.box'类更改为
box1
box2
等,并根据需要定位它们,而不是内部div。像泥一样清澈。