I am having an HTML layout like follows.
<div class="container">
// Some contents are here in this level
<div class="sub-container">
// Some contents are here in this level
<div class="sub-sub-container">
// Some contents are here in this level
......
.....
.....
.....
.....
......
</div>
</div>
</div>
<div class="dynamically_added">
<div class="container">
// Some contents are here in this level
<div class="sub-container">
// Some contents are here in this level
<div class="sub-sub-container">
// Some contents are here in this level
......
.....
.....
.....
.....
......
</div>
</div>
</div>
</div>
The problem is that, when I am trying to update the sub-container or sub-sub-container (simply any div nested deep inside the main (original) container div) div it is updating the contents of the dynamically added container also. How can I prevent it, so that only the original contents are updated?
You could use
.filter()to excludedivs that are inside.dynamically_added:Thus, in your example, this will filter out every
divthat matches the selector that are within thedivwith the class.dynamically_added, and include all others.DEMO.