Hi I am starting to use jQuery and when I try to select the content inside a div, some emails don’t get selected? I’m using Safari’s console to execute the jQuery code. I get the desired result with .text() but why doesn’t .html() work?
jQuery
$("input[type=checkbox]:checked").parents('.organizer_listing').find('.organizer_listing_contact_email')
Result
[
<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>
]
jQuery
$("input[type=checkbox]:checked").parents('.organizer_listing').find('.organizer_listing_contact_email').html()
Result
"ciara@bhre.net"
The accessor methods (most of which can be mutators too, but anyway) will only work on the first item in the result set.
That is,
.html()will give you the html of the first item in the set, just as.attr('href')will give you the first item’shrefattribute.Instead, you might want to use
.map