Ajax替换而不是追加 [英] Ajax replace instead of append

查看:166
本文介绍了Ajax替换而不是追加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了以下jQuery 示例,其中奇迹般有效.但是,它会附加结果.我需要更改什么以替换结果而不是附加结果?

I used the following jQuery example which works like a charm. However it appends the results. What do I need to change to replace the results instead of appending?

推荐答案

您可以在追加之前清空元素

you could empty the element before you append

$("#results").empty().append(myHtml);

或使用html方法

$("#results").html(myHtml)

这篇关于Ajax替换而不是追加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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