Q
Q
Qurel2020-11-09 15:04:43
JavaScript
Qurel, 2020-11-09 15:04:43

How to check if there are other tags in a tag or tags and delete them?

How to check if there are other tags in a tag or tags and delete them?
This entry doesn't work: if(redactorText. match(/(<([^>]+)>)<\/p>/ig))
<textarea class="js-redactor"></textarea>

$('.js-redactor').on('change', function(){
  var redactorText = $(this).val();
  var regex = /(<([^>]+)>)/ig;
  if(redactorText.match(/<p>(<([^>]+)>)<\/p>/ig)) {
    //этот код убирает все теги в textarea, а не между тегами <p></p> или <p><ins></ins></p>
    redactorText = redactorText.replace(regex, "");
    $(this).val(redactorText);
  }
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2020-11-09
@Qurel

See what I can. No regulars . Magic, nothing else :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question