I want to write a function in JavaScript that parses through all visible text on a website and performs a simple function on them.
The following code example uses JQuery:
$("*").each(function() {
var t = $(this).text();
if (t != "") {
t = t.toUpperCase();
}
});
Note: I understand that there are ways to perform similar functions to the above example in CSS. My intended use is to convert all roman text into an alternate Unicode writing system for the purpose of writing system learning, but I want to understand the fundamentals first.
The above does not function as intended as it pulls significantly more of the front-end code than I'm looking for. I looking for a function that only returns instances of text in:
- Form items (Buttons, input, etc...)
- Links
- General page body text
How could I modify the above function to return the results I'm looking for?