I am trying to translate some html elements based on the interface language of a system. The structure is simple and consists of a list, with a elements inside each il element, like so:
<li class="toolbar">
<a>"Some Text"</a>
</il>
I made a selection based on this structure and everything works as it should:
$(".toolbar a").each(function(){
if ($(this).text().includes("Some Text")) {
$(this).text("טקסט כלשהו");
However, the interface is responsive, and when the mobile version kicks in, the structure slightly changes, and now a ::before element is suddenly added, like so:
<li class="toolbar">
<a>::before "Some Text"</a>
</il>
This ::before statement makes my code not read the a element correctly, and the text does not change.
Because I am using an .each function to translate all elements together, I can't use CSS:before statements, because I will have to define each one separately, which I am trying to avoid.
How can I select the text in the a element despite the ::before? I tried adding it to the selector, like so:
$(".toolbar a::before").each(function(){
if ($(this).text().includes("Some Text")) {
$(this).text("טקסט כלשהו");
But to no avail. I searched online for an answer, but I keep getting references to CSS "Before" selector.