How to parse editable DIV's text with browser compatibility

后端 未结 3 469
孤街浪徒
孤街浪徒 2021-01-14 07:33

I make div as editable. while i tried to parse div\'s text, i was needed to do the below regular expression.

innerDOM = \"
3条回答
  •  [愿得一人]
    2021-01-14 07:59

    //FINAL ANSWER
    var domString = "", temp = "";
    
    $("#div-editable div").each(function()
                {
                    temp = $(this).html();
                    domString += "
    " + ((temp == "
    ") ? "" : temp); }); alert(domString);

    see this fiddle for answer.

提交回复
热议问题