简体   繁体   English

jQuery Find()在Firefox或IE中不起作用

[英]jQuery Find() not working in Firefox or IE

I'd like to change the attribute of a Google Calendar select element. 我想更改Google日历select元素的属性。

The code I'm trying works in WebKit browsers, but not in FF or IE. 我正在尝试的代码可在WebKit浏览器中使用,但不适用于FF或IE。

Here's what I have: 这是我所拥有的:

$jqry('iframe').contents().find('.calendar-nav').attr('style','display: table; background: blue');

I think it's getting stuck on the find() function. 我认为它卡在find()函数上了。 Is my iframe being treated as ajax? 我的iframe是否被视为Ajax? Is the issue being caused by mime/content type? 问题是由mime / content类型引起的吗? Please help with a code example if possible. 如果可能,请提供代码示例的帮助。

Many thanks! 非常感谢!

Try this, 尝试这个,

Chrome/Firefox: Chrome / Firefox:

xml.children[0].childNodes[1].innerHTML

IE8+/Safari: IE8 + / Safari:

xml.childNodes[0].childNodes[1].textContent

IE8: IE8:

xml.documentElement.childNodes[1].text;

I found a solution that worked for me. 我找到了对我有用的解决方案。 It seems Firefox and IE didn't like the vagueness of having only a tag selector: $('iframe') . 似乎Firefox和IE不喜欢仅具有标签选择器的模糊性: $('iframe') As soon as I added a class it worked: $('.myiframe') . 一旦添加了一个类,它就会起作用: $('.myiframe') I'm guessing an ID would work just the same: $('#myiframe') . 我猜想一个ID会一样工作: $('#myiframe') I was only using the tag selector because I didn't want to modify the plugin I was using, and it was the only iframe on the page -- oh well. 我之所以只使用标签选择器,是因为我不想修改我正在使用的插件,它是页面上唯一的iframe,哦。 Thanks to those who provided input. 感谢那些提供意见的人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM