Skip to content Skip to sidebar Skip to footer

Jquery: How Do I Remove Surrounding Div Tags?

In this line...
lorem ipsum dolor sit amet
I'd like to get rid of the surrounding div tags with jQuery so the output looks like this: lor

Solution 1:

$('.textwidget').contents().unwrap();

should work

Solution 2:

$('.textwidget').replaceWith($('.textwidget').text());

Should do it.

Solution 3:

This will select the text and removes the div tag around it.

$('.textwidget').contents().filter(function() {
    returnthis.nodeType === 3
}).unwrap();

Check working example at http://jsfiddle.net/7SX5u/1/

Solution 4:

$('.textwidget').replaceWith($('.textwidget').html());

Post a Comment for "Jquery: How Do I Remove Surrounding Div Tags?"