Use jQuery's .load() to load page fragments but only get contents of selector -


i using jquery's .load() page fragments method reload piece of page:

$("#submit").click(function() {     $("#box").load('/ajax/box/ #box'); }); 

it works, causing error because after contents loaded. since function uses .innerhtml replacing code on inside of div. html result looks like:

<div id="box">     <div id="box">         <!-- page -->     </div> </div> 

i have tried using .parent() removes other divs in parent.

$("#submit").click(function() {     $("#box").parent().load('/ajax/box/ #box'); }); 

essentially trying (i know code below invalid, represents trying accomplish):

$("#submit").click(function() {     $("#box").load('/ajax/box/ $('#box').html()'); }); 

is there way can make #box replaced #box?
1 thing keep in mind cannot edit html, needs happen jquery only.

just add > * after #box

$("#submit").click(function() {     $("#box").load('/ajax/box/ #box > *'); }); 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -