Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

113
Vistas
Finding and replacing attribute in HTML File

I have a project folder which contain list of HTML file which contain some knockout syntax , I am looking some pointer where are I search for certain pattern of attribute and replace it will new syntax.

I tried something with JSDOM but was not successful.

Structure of HTML file is something like this , here I have find all occurrences of data-bind="attr :{id : <>}" and replace it with :id="[[componentid]]"

    <div data-bind="attr :{id :componentid}" class="">
      <div class="formlayout">
        <input type='textbox>
      </div>
    </div>
   <div data-bind=" attr :{id :  pageid}" class="">
      <div class="formlayout">
        <input type='textbox>
      </div>
    </div>

After the change HTML file should look like below.

<div :id="[[componentid]]" class="">
      <div class="formlayout">
        <input type='textbox>
      </div>
    </div>
   <div :id="[[pageid]]" class="">
      <div class="formlayout">
        <input type='textbox>
      </div>
    </div>

Note: There can be multiple whitespace for the data-bind property we should ignore those. I was trying with JSDOM and node js but was not successful and pointer will be really helpful

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

you can try this...

<script>
  const getElement1 = document.querySelector(".data1");
  const getElement2 = document.querySelector(".data2");

  getElement1.removeAttribute("data-bind");
  getElement1.setAttribute(":id", "[[componentid]]");

  getElement2.removeAttribute("data-bind");
  getElement2.setAttribute(":id", "[[pageid]]");
</script>
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda