I've been working on trying to style the html CODE element by adding an ordered list on top of its content and then a a LI and a P before each new line, with their closing tags added to the end of each line.
This is what I have:
$("#mydiv code").each(function(){
var oldcontent = $(this).html();
$(this).html("" + oldcontent + "");
var lines = oldcontent.split(/[\n\r]/g);
$.each(lines, function(e){
$(this).html("
" + lines + "
");
});
});
This simply doesn't work. I get no errors, I don't know what is wrong.
Does anybody know how to fix this?
Thanks!
以上就是Jquery - Adding html before each new line in an array的详细内容,更多请关注web前端其它相关文章!