Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

207
Visualizações
Change HTML text without direct access to HTML

I'm building a website in a website builder, but I would like to change the default message that appears when some required field in the website form is not filled. The form I am referring to is an element of the website builder itself.

Is there any way I can change HTML text without having direct access to it?

I can add code to the <head>, but I don't believe it changes existing code.

The paragraph I would like to change is this:

<div data-v-3a756488=""><p data-v-3a756488="" class="input__error-message z-body-small"> Esse campo é obrigatório </p></div>

I was studying some possible improvised solutions using CSS, one of them would be to hide the text that appears in the HTML and put another one in the content of the CSS, but I know it's not the best way.

I have the possibility to use CSS, HTML and JavaScript, the site accepts any of these languages ​​in the <head> and in embedded code elements.

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

First you add an eventListener to check if all the DOM elements have been loaded with window.addEventListener('load', ... Then you select the element you want to change. In this case I targeted the paragraph with a data-attribute in the hope that this is an unique element with that data-attribute: document.querySelector('p[data-v-3a756488=""]'). Then I use textContent on that element to replace the text:

window.addEventListener('load', function() {
  let ele = document.querySelector('p[data-v-3a756488=""]');
  let text = 'This is the replaced Text';
  ele.textContent = text;
})
<div data-v-3a756488=""><p data-v-3a756488="" class="input__error-message z-body-small"> Esse campo é obrigatório </p></div>

If you have more than just 1 element where you want to replace the text, you can also use an array and object with the same method. You just create then an array of objects where you list the element you want to target and the text you want to replace with. Then you can use a for-loop to apply all changes defined in the array of objects:

window.addEventListener('load', function() {
  const replace = [
    { element: 'p[data-v-3a756488=""]',
      text: 'replaced text of the first element'
    },
    { element: 'p[data-v-3a756500=""]',
      text: 'replaced text of the second element'
    },
    { element: 'p[data-v-6a756488=""]',
      text: 'replaced text of the third element'
    }
  ];
  
  for (let i = 0; i < replace.length; i++) {
    let ele = document.querySelector(`${replace[i].element}`),
        text = replace[i].text;
    ele.textContent = text;
  }
})
<div data-v-3a756488=""><p data-v-3a756488="" class="input__error-message z-body-small"> This is Element 1 </p></div>

<div data-v-3a756500=""><p data-v-3a756500="" class="input__error-message z-body-small"> This is Element 2 </p></div>

<div data-v-6a756488=""><p data-v-6a756488="" class="input__error-message z-body-small"> This is Element 3 </p></div>

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda