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

89
Views
Prepend additoonal html to string

I am only accepting raw js answers, jquery will be downvoted.

I have the following string, lets call this MyHtmlAbove:

<span class="fc-title-wrap"><span class="fc-title fc-sticky">Some Sample Content here</span></span>

I know I can do:

el = document.createElement('div');
el.innerHTML = myHtmlAbove;

What I don't know how to do now is:

Find the class fc-title and before the content (prepend) and icon tag: <i class='font-awesome-here'></i>

I am unsure if I can just use the regular raw:

    el.findByClassName('fc-title').prepend('<i class='font-awesome-here'></i> ')

    // Result should be:
    <span class="fc-title-wrap"><span class="fc-title fc-sticky"><i class='font-awesome-here'></i> Some Sample Content here</span></span>

Can some one point me in the right direction, I feel I am close.

Since I have create a temp element to do this manipulation with, I would also like to clean it up so it's not hanging out in the dom some where it shouldn't be.

Thoughts?

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

 document.getElementsByClassName('fc-title')[0].prepend('<i class="font-awesome-here"></i> ')

    // Result should be:
   // <span class="fc-title-wrap"><span class="fc-title fc-sticky"><i class='font-awesome-her
<span class="fc-title-wrap"><span class="fc-title fc-sticky">Some Sample Content here</span></span>

    

about 4 years ago · Juan Pablo Isaza Report

0

document.getElementsByClassName('fc-title')[0].prepend('<i class="font-awesome-here"></i> ')
about 4 years ago · Juan Pablo Isaza Report

0

Raw Js() version:

const fcT = document.querySelector(".fc-title");
const t = fcT.innerText
const icon = "<i class='font-awesome-here'></i>"
fcT.innerHTML = icon + " " + t;

console.log(document.querySelector(".fc-title"));
<span class="fc-title-wrap"><span class="fc-title fc-sticky">Some Sample Content here</span></span>

about 4 years ago · Juan Pablo Isaza 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!