abrabr
abrabr

Reputation: 217

replaceWith jquery function

I know that this is most probably will be not that "clever" question, but i couldn't understand how this functions works, all i want from it, is just to remove <p> tags in the given table with class p_remove, here is my jquery code:

$(document).ready(function() {
    $('.p_remove').each( function(){
        $("<p>" + $('.p_remove').text() + "</p>").replaceWith("" + $('.p_remove').text() + "");
    });
});

this script is actually doesnt work, because the previous working scripts didnt work in the way i wanted them to work :) Thx for help!

Upvotes: 0

Views: 357

Answers (1)

BGerrissen
BGerrissen

Reputation: 21680

$('.p_remove').each( function(){
    $self = $(this)
    $self.replaceWith( "<p>" + $self.text() + "</p>" );
});

Upvotes: 2

Related Questions