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

186
Visualizações
js - marking bracket pair in input text box depending on cursor position

I'm working on a math project. Therefore I want to modify the 'input text'-Box. It should mark the bracket pair of the cursor i. e. the bracket positioned left and the one right from the cursor.

I already know, how to get the cursor position:

document.getElementById('inutField').addEventListener('keyup', e => {
  console.log('pos: + e.target.selectionStart)
})

Now I thought about formatting a string

str = '3*<span>(</span>4+5<span>)</span>*6

formatting the span tag (maybe bold) and put it into the Text field with

document.getElementById('inputField').value = str;

Unfortunately the value variable doesn't take formatted strings, so it won't work.

Mayby someone has an idea or there is a library that already solves the problem?

Thanx for your help...

Philipp

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It seems like an overkill but you could use one of the WYSIWYG editor libs. The most popular are:

  • https://quilljs.com/
  • https://ckeditor.com/
about 4 years ago · Juan Pablo Isaza Relatório
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