Using .replaceWith to remove <p> tags but keep content inside tags?
css, html-table, jquery
Solution
Try:
$('.address p').contents().unwrap();
Example: http://jsfiddle.net/6zAN7/34/ (uses `div` instead of `td` but the concept should be the same)
Explanation:
`contents` gets elements inside the paragraph tag (including text elements), and then calls `unwrap` on those text elements, removing the parent `p` tag.
Problem
I have a table cell containing content that's wrapped in `<p>` tags: ``` <td class=" address"><p> Content goes here </p></td> ``` I want the `<p>` tags removed so it looks like this: ``` <td class=" address"> Content goes here </td> ``` I tried the following jQuery, but it didn't work. Can someone point me in the right direction? ``` $('.address p').replaceWith(''); ```