Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
I have, for example, the following <object> in my page:
<object>
<object id="obj1" data="URL"></object>
Is there any way to get the html object in jquery?
As with any element with an id: jQuery('#obj1')
jQuery('#obj1')
Or to get all object elements: jQuery('object')
jQuery('object')
与任何具有 id 的元素一样:jQuery('#obj1')
或获取所有对象元素:jQuery('object')
"jQuery get html"
It seems like you're asking how to get the HTML rendering of the element.
If so, do this:
var markup = $("#obj1")[0].outerHTML;
Or using .prop():
.prop()
var markup = $("#obj1").prop("outerHTML");
Or without jQuery:
var markup = document.getElementById("obj1").outerHTML;