Example 1 — Official span:last-of-type
Mark the last span in each div (official demo idea, CSS-free).
$("span:last-of-type").text(function (i, text) {
return "[last] " + text;
}); How It Works
- Select.
span:last-of-typefinds the last span among siblings. - Per parent. Each div contributes at most one match for that tag.
- Update.
.text()prefixes the matched names.

