开发者

jquery .html() doesn't work in IE if an OBJECT tag is used

开发者 https://www.devze.com 2023-03-11 04:47 出处:网络
I have the following code: <div 开发者_C百科id=\"object-container\"> <object data=\"some-file.swf\">

I have the following code:

<div 开发者_C百科id="object-container">
    <object data="some-file.swf">
        <param name="src" value="some-file.swf" />
    </object>
</div>

I want to grab the contents of #object-container and inject them into a different place on the page. The code I have to do this works fine in firefox, but in IE it's only getting the opening and closing object tags, not the param tags:

var code = $('#object-container').html();
$('#other-div').html(code);

Does anyone know how to reliably get the FULL HTML out of a div in IE?

EDIT: All other tags are working in IE

$('#other-div').html("Other HTML Code Displays Correctly <h1/>");

Thanks all


I've no idea why this happens on IE, you can try to use only javascript to do it:

var code = document.getElementById('object-container').innerHTML;
$('#other-div').html(code);
// or document.getElementById('other-div').innerHTML = code;

Hope this works


Replace your JS code with $('#object-container').clone().appendTo('#other-div');

0

精彩评论

暂无评论...
验证码 换一张
取 消