Thursday, April 19, 2012

jquery simple ajax load without loading its wrapper DIV

I have a content (#content) at external file (test.html) to load into another DIV (#result) at index.html:



test.html:



<div id="content>This text should not be loaded with its DIV</div>


jquery:



$('#result').load('test.html #content');


index.html result, unexpected:



<div id="result><div id="content>This text should not be loaded with its DIV</div></div>


index.html result, expected:



<div id="result>This text should not be loaded with its DIV</div>


How do you load only the actual content/ text of the #content without loading its wrapper (#content)?
The reason is to simply avoid unneeded divities which also may conflict with other styled DIVs by mistake.



Any hint is very much appreciated. Thanks





No comments:

Post a Comment