📜 ⬆️ ⬇️

Ajax load data from container

Did you know that using jQuery you can load not only the page content, but also the selected container on it? It turns out that it can and is done as follows:
$("#area").load("something.html #content"); 

This code will find a container with id content on the something.html page, take its contents and load it into a container with id area . But there is one thing ...

And it looks like this:
 $("#area").load("something.html #area"); 

The result of this code will be the following result:
 <div id="area"> <div id="area"> <!-- stuff --> </div> </div> 

And the further, the more nested this code will be.

The solution is:
 $("#area").load("something.html #area > *"); 

A demo can be found here .

')

Source: https://habr.com/ru/post/112779/


All Articles