0

I have, for example, the following <object> in my page:

<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')

Or to get all object elements: jQuery('object')

4

2 回答 2

4

与任何具有 id 的元素一样:jQuery('#obj1')

或获取所有对象元素:jQuery('object')

于 2012-10-07T17:11:50.110 回答
3

"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():

var markup = $("#obj1").prop("outerHTML");

Or without jQuery:

var markup = document.getElementById("obj1").outerHTML;
于 2012-10-07T17:17:37.780 回答