-1

I want to change into with jquery (so that I can link a class to ), but i have no idea how i must do that. Can anybody help me with it?

$(function() {
   $('#span').on('click', function () {
            document.execCommand('formatBlock', false, '<blockquote>');
            $('blockquote').replaceWith(function(){
                return $("<span class='bq' />", {html: $(this).html()});
            });

            var text = $('#textarea').html();
            console.log(text);
            let bq = $('#textarea').find('blockquote').first();
            console.log(bq.text());
            $('#textarea-show').html(text);
            $('textarea#answerstextarea').html(text);
        });
        console.log()

        $('.saveBtn').click(function(event) {
            event.preventDefault();
            let data = $( "div#textarea" ).html();
            $('textarea#answerstextarea').html(data);
           $('#question-create-form').submit();

        })
      
  document.getElementById('answerstextarea');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div contenteditable="true" id="textarea" name="answers" class="form-control">{!! old('answers',$task->description) !!}</div>
<textarea name="answers" id="answerstextarea"></textarea>
Marianne
  • 39
  • 10

1 Answers1

1

Did you try something like this ?

$('blocquote').replaceWith(function(){
    return $("<span />", {html: $(this).html()});
});
RedKen
  • 147
  • 7