Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

117
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!