【问题标题】:JQuery Effect Multiple ElementsjQuery 效果多个元素
【发布时间】:2009-02-02 20:43:05
【问题描述】:

试图用一个load() 击中两个元素,但我尝试的却没有成功。这就是我现在必须刷新页面上的一个部分,它工作正常。

$('#refreshme_'+request).load("http://www.example.com/add_list/");

我试过了

$('#refreshme_'+request, .xPlanner).load("http://www.example.com/add_list/"); 

这根本不起作用。想让我的代码高效,并且需要一次调用刷新 2 个 DOM。有什么想法吗?

【问题讨论】:

    标签: ajax jquery


    【解决方案1】:
    var request = "foo";
    $("#refreshme_" + request + ", .xPlanner").load("http://www.example.com/add_list/");
    

    <div id="#refreshme_foo">Lorem</div>
    <div class="xPlanner">Ipsum</div>
    

    有效。这是你想要做的吗?

    【讨论】:

      【解决方案2】:

      我想知道你是否不能使用类似的东西:

      $.get("http://www.example.com/add_list/", function(data) {
          $('#refreshme_'+request).html(data);
          // same for second
      });
      

      【讨论】:

        【解决方案3】:

        你会想要使用 .get 代替:

            $.get("http://www.example.com/add_list/", function(data) {
                $("#refreshme1").html(data);
                $("#refreshme2").html(data);
            });
        

        这是假的,但你明白了。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2010-11-30
          • 2014-10-13
          • 1970-01-01
          • 2012-03-30
          • 2018-07-20
          • 2011-12-20
          • 1970-01-01
          • 2014-11-04
          相关资源
          最近更新 更多