简体   繁体   English

我没有在MAC上的Safari 7.1中使用jQuery选择HTML元素的对象

[英]I Don't get an object selecting an HTML element using jQuery in Safari 7.1 on MAC

I'm trying to get the HTML content of an element using jQuery, works fine on each browsers I've tested such as Chrome Firefox Opera.. but with Safari 7.1 on MAC... it's not working I just get an Array containing the element. 我正在尝试使用jQuery来获取元素的HTML内容,在我测试过的每个浏览器(例如Chrome Firefox Opera上)都可以正常工作。但是在MAC上使用Safari 7.1时……无法正常工作,我只是得到一个包含元件。 So if I do that: 因此,如果我这样做:

console.log($('#myElement').parent().find('svg').html());

I get this in my console. 我在控制台中得到它。

Error: undefined is not an object (evaluating 'b.innerHTML.replace')

Even if I do that it doesn't work: 即使我这样做也不起作用:

console.log($($('#myElement').parent().find('svg').html()));

Thank you in advance. 先感谢您。

input is a singular or self-closing tag. 输入是单数或自闭标签。 I am not sure what are you trying get from this element. 我不确定您要从这个元素中得到什么。 But if you are looking to check whether the checkbox is marked or not you can follow the following example [Example][1] 但是,如果您要检查复选框是否已选中,则可以按照以下示例[示例] [1]

 [1]: http://jsfiddle.net/5udtC/

See, jquery object always returns an object on which any jquery method or handler can be applied. 请参见,jquery对象始终返回一个对象,可以在其上应用任何jquery方法或处理程序。

I don't why its not woking for you. 我不明白为什么它对你不起作用。 Anyhow, Try this 无论如何,尝试一下

console.log($($('#checkbox')));

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

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