Jquery - Adding html before each new line in an array

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前端其它相关文章!

    赞(0) 打赏
    未经允许不得转载:web前端首页 » jQuery 答疑

    评论 抢沙发

    • 昵称 (必填)
    • 邮箱 (必填)
    • 网址

    前端开发相关广告投放 更专业 更精准