jquery replace all <ol> with <ul>

javascript, jquery, regex

Solution

ok i had to work from the inside to the outside, only replaceWith wasn't working because it replaced only the outer tags and didn't replace the inner ones, so i solved it this way:

$($('.wrapper').find('ol').get().reverse()).each(function(){
  $(this).replaceWith($('<ul>'+$(this).html()+'</ul>'))
})

if someone has a better solution i would be glad to hear it.

Problem

Given the following dom structure I would like to transform an ordered list to an unordered list. ``` <div class="wrapper"> <ol> <li><div>foo</div></li> <ol> <li><div>bar</div></li> </ol> <li><div>batz</div></li> </ol> </div> ``` What is the best way to do this?

Original source

Related problems