I am creating a keyboard access library for my web application. To hint which keys to press, I want to underline the key in the links. For instance.
O rders --- I nvoices --- Ope n Incidents
For pure snippets of text, this is simple (jQuery is used here):
part.html(part.html().replace(new RegExp(key, 'i'), '<u>$&</u>'));
But it breaks terribly if partthere is any html markup inside . Is there an elegant way to just update text nodes and not markup?
Clarification: my use case is hundreds of server-side nested templates that generate HTML. Attributes accesskeyare currently being added manually. The result of something like <a href="angebote.html" accesskey="t"><i class="fa fa-fw fa-podcast"></i>Ange<b>bote</b></a>. Javascript Front-End Script then, among other things, adds key bindings and tries to emphasize the associated keys.
source
share