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 div
s 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
Post a Comment