Reputation: 13509
I have a collection of divs on a page with the same class name.
<div class="ProductName">Product Foo</div>
<div class="ProductName">Product Bar</div>
I would like to be able to retrieve, iterate through and this case alert the ProductName div's contents.
Currently I can retrieve and iterate, but I can't alert the individual contents.
var ExistingProductNamesOnscreen = $.makeArray($(".ProductName"));
$.each(ExistingProductNamesOnscreen, function (key, val) {
alert(*ProductName contents*);
});
Upvotes: 1
Views: 1500
Reputation: 11859
did you try
alert ($(this).text());
or
alert ($(this).html());
?
(The first should alert text
contents, while the latter also any tags found in particular div
)
Upvotes: 0