jQuery“Object不支持此属性或方法”在Internet Explorer中 [英] jQuery "Object doesn't support this property or method" in Internet Explorer

查看:240
本文介绍了jQuery“Object不支持此属性或方法”在Internet Explorer中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery向网站添加一些动态内容。

I am using jQuery to add some dynamic content to a website.

我正在尝试使用以下代码按需创建一个新的DOM元素: p>

I am attempting to create a new DOM element on-demand using the following code:

container = $('<div id="myContainer"></div>');

这在Firefox和Safari中完美工作,但Internet Explorer正在生成错误。 IE错误是:对象不支持此属性或方法

This works perfectly in Firefox and Safari, but Internet Explorer is generating an error. The IE error is: Object doesn't support this property or method

我知道jQuery正确加载,并尝试过 jQuery $ 语法。

I know that jQuery is loading properly, and have tried both the jQuery and $ syntax.

任何可能导致这种情况的想法?

Any ideas as to what might be causing this?

推荐答案

如果要添加DOM元素,代码需要修改了一下:

If you want to add a DOM element, the code needs to be modified a bit:

$('body').append('<div id="myContainer"></div>');
// body can be whatever containing element you want to hold myContainer
$('#myContainer').html('whatever you want inside of myContainer');

这篇关于jQuery“Object不支持此属性或方法”在Internet Explorer中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆