How can I check if a tag or tags have other tags and remove them?

  • 0
    How to check if there are other tags in a tag or in tags and remove them?
    This entry doesn't work: if (redactorText.match (/ (& lt; ([^ & gt;] +) & gt;) & lt; \ / p & gt; / ig))
    & lt; textarea class = "js-redactor" & gt; & lt; / textarea & gt;
    $('.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);
    	}
    });
    JavaScript Olivia Hensley, Oct 20, 2020

  • 2 Answers
  • 0
    Look what I can. No regulars . Magic, not otherwise :)

    Anonymous

  • 0
    function simplify(node){
    return node.textContent;
    }

    simplify(document.querySelector('.js-redactor'));
    Anonymous

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!