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

118
Vistas
position a text element relative to another

I have a form that carries info from one HTML to another using local storage. Since this text changes based on what the user inputs on the first HTML, I have to find a way to add a text element that stays with the output. For example: if a user types "Luke" and submits, ideally the next page will say "Luke's" (the "'s" being the separate text element). Since the text might be longer e.g. Lukas or Lucius, the "'s" text element has to stay at the end of the previous one regardless of its length.

<h1 id="show">
<!-- this is where the output text shows -->
      </h1>
<h1 class="epic1">'s epic <!-- this is what i want to stick to the  end of the output element -->
</h1>

I should also add that this JS isn't working...

  <script>
      
      document.getElementById("show").textContent += "'s";
    </script>
about 4 years ago · Santiago Gelvez
2 Respuestas
Responde la pregunta

0

You can use an :after pseudo element for this. Its defined content will be added to any element that has the class it refers to, and it will be automatically styled the same way as the element it's appended to:

.epic1:after {
  content: "'s epic";
}
<h1 class="epic1">Tom</h1>

about 4 years ago · Santiago Gelvez Denunciar

0

Not sure if it's the best way, but I added a div with a new class around the show element and used the ::after in css to add content.

.hey ::after {
  font-weight: bold;
  color: black;
  content: "'s";
}
<div class="hey">
  <h1 id="show">
  </h1>
</div>

about 4 years ago · Santiago Gelvez 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