D
D
Denis Bukreev2015-11-11 18:42:09
JavaScript
Denis Bukreev, 2015-11-11 18:42:09

JS script removing all p tags from a specific block?

Good

Let's say there is a block with id="outer"

And it is necessary that all tags inside it be deleted and How will such a script look like? <p></p>

Answer the question

In order to leave comments, you need to log in

4 answer(s)
R
riot26, 2015-11-11
@denisbookreev

jsfiddle.net/qmxkja11

M
Maxim Nepritimov, 2015-11-11
@nepritimov_m

Maybe like this
HTML:

<div id="outer">
    <p> бла бла </p>
    <p> бла бла </p>
    <p> бла бла </p>
    <p> бла бла </p>
    <p> бла бла </p>
    <p> бла бла </p>
</div>
<input type="button" class="but" value="click">

JS:
$('.but').on('click', function () {
    var $outer = $('#outer'),
    	$p = $outer.find('p');
    $p.each(function () {
      $(this).remove();
    });
});

Y
Yaroslav Lyzlov, 2015-11-11
@dixoNich

$('#outer').find('p').remove()

V
Vitaly Inchin ☢, 2015-11-11
@In4in

$("#outer").find("p").each(function(){
   var $this = $(this);
   $this.replaceWith( $this.html() );
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question