I have a lot of <tr> elements. Each important one is marked with a class name containing "highlight-delete". How can I iterate over the whole set of them, and write each of their .innerHTML to the console? I tried this but it failed
$.each('tr[class*=highlight-delete]', function (index, item) {
console.log(item.innerHTML);
});
The first parameter of the each function should be an array or object, you are passing a string:
jQuery.each( collection, callback(indexInArray, valueOfElement) )
$.each($('tr[class*=highlight-delete]'), function (index, item) {
console.log(item.innerHTML);
});
You can use jquery's html() function
$('tr[class*=highlight-delete]').each(function (index, item) {
console.log($(item).html());
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With