Let me clarify my need, it might not be all clear from the title.
I am using:
$("#content").load("http://example.com/page1.html #content");
When I look in firebug I see #content inside #content on the page where Ajax call occurred.
So it's obvious that I need only #content's inner html to get loaded. What would be the most elegant way to achieve this with Jquery.
Thank you!
The standard JavaScript innerHTML property is similar to .html () method. Both return or set HTML content. The .html () jQuery cannot be used on documents in XML format. All HTML elements have inner HTML properties. The .html () jQuery method retrieves the HTML content of the first element in the particular set of matched elements.
The .html () jQuery cannot be used on documents in XML format. All HTML elements have inner HTML properties. The .html () jQuery method retrieves the HTML content of the first element in the particular set of matched elements. Remember: jQuery innerHTML does not exist as a function. Use .html () jQuery to set or get HTML content.
In jQuery, innerHTML is retrieved with the following syntax of html: $(selector).html(); If you need to make jQuery .html() overwrite HTML content, use this syntax:
Description: Wrap an HTML structure around the content of each element in the set of matched elements. An HTML snippet, selector expression, jQuery object, or DOM element specifying the structure to wrap around the content of the matched elements. A callback function which generates a structure to wrap around the content of the matched elements.
Use the Child Selector (http://api.jquery.com/child-selector/) on #content to select all (*) the children of #content.
$("#content").load("http://example.com/page1.html #content > *");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With