Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery.html()不选择某些电子邮件?_Javascript_Jquery - Fatal编程技术网

Javascript jQuery.html()不选择某些电子邮件?

Javascript jQuery.html()不选择某些电子邮件?,javascript,jquery,Javascript,Jquery,嗨,我开始使用jQuery,当我尝试选择div中的内容时,有些电子邮件没有被选中?我正在使用Safari的控制台执行jQuery代码。我使用.text()获得了想要的结果,但是为什么.html()不起作用呢 jQuery $("input[type=checkbox]:checked").parents('.organizer_listing').find('.organizer_listing_contact_email') $("input[type=checkbox]:checked")

嗨,我开始使用jQuery,当我尝试选择div中的内容时,有些电子邮件没有被选中?我正在使用Safari的控制台执行jQuery代码。我使用
.text()
获得了想要的结果,但是为什么
.html()
不起作用呢

jQuery

$("input[type=checkbox]:checked").parents('.organizer_listing').find('.organizer_listing_contact_email')
$("input[type=checkbox]:checked").parents('.organizer_listing').find('.organizer_listing_contact_email').html()
结果

[
<div class=​"organizer_listing_contact_email">​ciara@bhre.net​</div>​
, 
<div class=​"organizer_listing_contact_email">hihi-p38sn-2788580457@somewhere.org​</div>​
, 
<div class=​"organizer_listing_contact_email">hihi-2xxtn-2783323299@someowhere.org​</div>​
]
"ciara@bhre.net"
结果

[
<div class=​"organizer_listing_contact_email">​ciara@bhre.net​</div>​
, 
<div class=​"organizer_listing_contact_email">hihi-p38sn-2788580457@somewhere.org​</div>​
, 
<div class=​"organizer_listing_contact_email">hihi-2xxtn-2783323299@someowhere.org​</div>​
]
"ciara@bhre.net"
返回jQuery对象的集合。您需要迭代该集合中的元素。您可以使用以下方法:

var $emails = $("input[type=checkbox]:checked").parents('.organizer_listing').find('.organizer_listing_contact_email');

$emails.each(function() {
    console.log($(this).text());
});
返回jQuery对象的集合。您需要迭代该集合中的元素。您可以使用以下方法:

var $emails = $("input[type=checkbox]:checked").parents('.organizer_listing').find('.organizer_listing_contact_email');

$emails.each(function() {
    console.log($(this).text());
});
访问器方法(大多数方法也可以是变异器,但无论如何)只对结果集中的第一项起作用

也就是说,
.html()
将为您提供集合中第一个项目的html,就像
.attr('href')
将为您提供第一个项目的
href
属性一样

相反,您可能希望使用

访问器方法(大多数方法也可以是变异器,但无论如何)只对结果集中的第一项起作用

也就是说,
.html()
将为您提供集合中第一个项目的html,就像
.attr('href')
将为您提供第一个项目的
href
属性一样

相反,您可能希望使用


.html()只能返回字符串。它无法返回字符串数组这里的文档是您的朋友:
html()
Description:获取匹配元素集中第一个元素的html内容。
.html()只能返回字符串。它无法返回字符串数组这里的文档是您的朋友:
html()
Description:获取匹配元素集中第一个元素的html内容。