Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.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
Javascript jquery获取从文件加载的元素_Javascript_Jquery_Html - Fatal编程技术网

Javascript jquery获取从文件加载的元素

Javascript jquery获取从文件加载的元素,javascript,jquery,html,Javascript,Jquery,Html,我在div中多次从html文件加载表单。我想循环浏览在这个div中创建的这些元素 我编写了以下代码以在每次单击按钮时加载文件: function addForm() { file = "field.php"; $(document).ready(function() { $("#ctrl_fields").append( $('<div />').load(file)); }); } 哦,将加载到追加中的空元素中。这种分类违背了目的,您可能

我在div中多次从html文件加载表单。我想循环浏览在这个div中创建的这些元素

我编写了以下代码以在每次单击按钮时加载文件:

 function addForm()
{
    file = "field.php";
    $(document).ready(function() {
        $("#ctrl_fields").append( $('<div />').load(file));
    });
}

哦,
加载到
追加
中的空元素中。这种分类违背了目的,您可能应该使用
$.ajax
$。以常规方式获取
。我没有装载空元素。我每次都会多次将文件加载到空分区中。谢谢aldux。我现在进入主舱。但是如何把元素放在那里。例如,我想读取该文件中某个输入中的文本:我写了这个,但它不起作用:alert($(this).getElementById('txt_len').value)
$("#ctrl_fields").each(function(){

   // do something here

});
$("#ctrl_fields > div ").each(function(){
   $(this).doSomething(); //this is the current div
});