jQuery的负载功能,将追加到HTML已经present [英] Jquery load function that will append onto HTML already present

查看:100
本文介绍了jQuery的负载功能,将追加到HTML已经present的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使一个AJAX调用,将追加HTML即增加额外的HTML是什么已经$标记之间p $ psent。这里是我的装载功能的模样。

I am trying to make an AJAX call which will append html i.e. add additional html to what is already present between the tags. Here is what my load function looks like.

<script>
    $(document).ready(function(){
      $(".tid-select").change(function(){
        $(".tid-list").load("/saffron_main/test");
      });
    });
</script>

我将如何修改这个功能才能得到它附加到类.tid名单。先谢谢了。

How would I modify this function in order to get it to append to the class .tid-list. Thanks in advance.

推荐答案

或不是取代你可以将数据加载到一个变量,然后将其添加到DOM的HTML

Or instead of replacing the html you can just load the data into a variable and then add it to the DOM.

例如:

$.ajax({
    url: '/saffron_main/test',
    success: function (data) {
        $('.tid-list').append(data);
    }
});

这样的事件已经被绑定到现有的HTML将保持绑定。

This way events that have been bound to the existing html will stay bound.

这篇关于jQuery的负载功能,将追加到HTML已经present的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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