JSFiddle - React, Tailwind, and code Playground

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://code.jquery.com/jquery-git.min.js"></script>
<input type="button" onClick="return false;" id="btn_highlight" unselectable="on" value="highlight" class="unselectable" alt="highlight" width="36" height="38">
<input type="button" onClick="return false;" id="btn_crossout" unselectable="on" value="crossout" class="unselectable" alt="crossout" width="36" height="38" />
<input name="highlight" id="highlight" type="text" value="17,114"/>
<input name="crossout" id="crossout" type="text" value="322,364"/>
<div class="highlight_area">
   <div id="high" class="question_area">
      <div class="question_stem">
         <p>A 47-year-old male with chronic kidney disease and peptic ulcer disease presents to the emergency room with chest pain. The patient states the pain increases with breathing and radiates to his back but improves with leaning forward. He states that he recently had a viral upper respiratory infection that left him with a cough for the past 3 weeks. An echocardiogram is ordered which appears normal. EKG shows diffuse ST segment elevations with PR depression. What is the most appropriate treatment at this time?</p>
      </div>
      <br>
   </div>
   <div class="input radio"><input type="radio" name="data[Answer][answer]" id="answer11" value="1"><label for="answer11">A.  NSAID only</label></div>
   <div class="input radio"><input type="radio" name="data[Answer][answer]" id="answer22" value="2"><label for="answer22">B.  Colchicine only</label></div>
   <div class="input radio"><input type="radio" name="data[Answer][answer]" id="answer33" value="3"><label for="answer33">C.  NSAIDS and colchicine</label></div>
   <div class="input radio"><input type="radio" name="data[Answer][answer]" id="answer44" value="4"><label for="answer44">D.  Corticosteroids</label></div>
   <div class="input radio"><input type="radio" name="data[Answer][answer]" id="answer55"...

CSS

.highlight{
  background:yellow;
}
.crossout{
  text-decoration: line-through;
}

JavaScript

$(document).on('click', '#btn_highlight', function() {
    select('#highlight');
    apply('highlight');
});
$(document).on('click', '#btn_crossout', function() {
    select('#crossout');
    apply('crossout');
});

function select(id) {
    function append(id, begin, end) {
        // console.log('Add: ' + begin + ' to ' + end);
        var highlights = $(id).val().trim().split(',');
        var start = -1;
        var done = -1;
        var duplicate = -1;
        var inside = -1;
        var out = [];
        var previous = 99999999;
        var on = false;
        for (x in highlights) {
            var mark = highlights[x];
            if (!mark) continue;
            // console.log('Check: ' + mark + ' Start: ' + start + ' End: ' + done);
            if (duplicate == mark) {
                // console.log('Repeated mark');
                out.push(mark);
            }
            if (done >= 0) {
                out.push(mark);
                continue;
            } else if (start < 0) {
                if (end < mark) {
                    // console.log('Prepend new');
                    out.push(begin);
                    out.push(end);
                    out.push(mark);
                    start = mark;
                    done = end;
                } else if (end == mark || begin < mark) {
                    if (!on && end <= mark) {
                        // console.log('Prepend consecutive');
                        out.push(begin);
                        out.push(end);
                        out.push(mark);
                        done = mark;
                    } else if (on) {
                        // console.log('Start inside');
                        inside = begin
                    } else {
                        // console.log('Start new');
                        out.push(begin);
                    }
                    start = begin;
                } else if (begin == mark) {
                    // console.log('Start...