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

