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

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

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 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!