Reputation: 11493
Here's an example doc structure
<div>
<div id="1" class="to-replace"></div>
<div id="2" class="to-replace"></div>
<div id="3" class="to-replace"></div>
</div>
What I want to do is replace #1
, for example, with whatever I retrieve from the ajax call (I'm not using JSON because the request is extremely small and it didn't seem worth it. Plus, the site is mostly for my personal use). I know I can use JQuery .load()
to replace the contents, but there must be some easy way to replace the whole thing.
Upvotes: 0
Views: 541
Reputation: 138
$.get(url,function(data){
$("#1").replaceWith(data);
});
where url is the url to whatever you want to get and data is the data that is returned
Upvotes: 3
Reputation: 1064
You can use the replaceWith jquery function to replace an element:
$("#1").replaceWith("bla");
Upvotes: 5