1

I am trying to load html content from another page via .load(). For example:

$('#myDiv').load('/myPage.aspx .anotherDiv *');

When I retrieve the content from .anotherDiv it renders the html incorrectly. For example,

<p><strong>text</strong></p> 

renders like this

<p></p>
<strong>text</strong>

Some how the "p" element is getting unwrapped then prepends to its original "strong" child element.

Any thoughts?

3
  • Note that the first arg of .load is URL which seems to be incorrect in your post. Just a comment. Commented May 9, 2012 at 18:30
  • @Vega He's using a valid overload which allows the implementer to specify a selector on the destination response. Commented May 9, 2012 at 18:31
  • @NathanTaylor Aaww I see, it is there in the documentation.. first time seeing such syntax. Commented May 9, 2012 at 18:33

1 Answer 1

2

I think you need to remove the * from your call to load().

$('#myDiv').load('/myPage.aspx .anotherDiv');

Let us know what happens.

Sign up to request clarification or add additional context in comments.

1 Comment

That worked! It includes the .anotherDiv. Is there a way to exclude it without using .unwrap()? I only want the innerHTML of .anotherDiv.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.