Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.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 - Fatal编程技术网

Javascript jquery中的动态容器名称

Javascript jquery中的动态容器名称,javascript,jquery,Javascript,Jquery,好的,我有多个按钮,它们用不同的ID调用相同的javascript函数 这是我的函数 function concur(id) { //alert(id); //throw ajax request $.ajax({ //create an ajax request to load_page.php type: "GET", url: "ajax_getter.php?requestid=1&r=" + id, dat

好的,我有多个按钮,它们用不同的ID调用相同的javascript函数

这是我的函数

function concur(id) {
    //alert(id);
    //throw ajax request
    $.ajax({ //create an ajax request to load_page.php
        type: "GET",
        url: "ajax_getter.php?requestid=1&r=" + id,
        dataType: "html", //expect html to be returned                
        success: function (response) {
            $("#container").html(response);
            //alert(response);
        }
    }); //ajax end
}
如果必须将
id
作为容器名称,我会怎么做? 我的意思是,这个
$(“#id”).html(响应)用于函数中所有动态变化的ID?

这对我不起作用。最好的解决方案是什么?

使用字符串连接在jQuery选择器中使用变量

$("#" + id).html(response); 

@阿列克夏:这不是问题吗?