Javascript jquery中的动态容器名称
好的,我有多个按钮,它们用不同的ID调用相同的javascript函数 这是我的函数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
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);
@阿列克夏:这不是问题吗?