jQuery加载页面的一部分,按变量ID选择 [英] jquery load part of page, select by variable ID

查看:65
本文介绍了jQuery加载页面的一部分,按变量ID选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用jquery .load()加载页面的一部分,问题是,我试图选择的div是一个变量

I am trying to load a portion of a page using jquery .load(), the the problem is, the div that I am trying to select is a variable

$('#additemsubmit').click(function(event){
    event.preventDefault();
    var location = $(this).parent();
    var reload = '#' + $(this).parent().attr('id');
    $(location).load("/index.php reload");
});

似乎我不能为位置"和重新加载"使用变量

It seems I cant use variables for "location" and "reload"

推荐答案

我认为这就是您想要的.

I think this is what you're looking for.

 var reloadId = '#' + $(this).parent().attr('id');
 $.get("/index.php", function(response) {
     $(location).html($(response).find(reloadId));
 });

这篇关于jQuery加载页面的一部分,按变量ID选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆