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

118
Visualizações
Superscript Toggle in js

I am trying to build a rich text editor from scratch.I am struggling while toggling on/off superscript.

I am using

var sel= window.getSelection()
var text=sel.toString()
var range=sel.getRangeAt(0)

document.addEventListener('changesupercript',
function({detail}){
if(isActive){
if(detail.verticalAlign='super'){
var sText=range.extractContents()
var span=document.createElement('span')
span.style.verticalAlign=detail.verticalAlign
span.appendChild(sText)
span.id='newspan'+text
span.className='supercript'
range.insertNode(span)
}
if(detail.verticalAlign='baseline'){
var children=document.getElementById(detail.active).children
for(var i=0;i<children.length;i++){
if(children[i].textContent === text){
var el=document.getElementById('newSpan'+text);
el.removeAttribute('style')
el.removeAttribute('id')
el.removeAttribute('className')
}
}
}
}
}
)

Any idea what might be going wrong

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