Creation and insertion of jquery elements

doing exercises on the creation and insertion of dynamic elements while watching the sharp jQuery

<ul id="ul">
            <li title=""></li>
            <li title=""></li>
            <li title=""></li>
        </ul>
            $("html"); // dom
            //li
            var $li_1 = $("<li></li>");
            //li
            var $li_2 = $("<li><li>");
            //   li
            var $li_3 = $("<li tltle = ""><li>");
            
            //
            // append()  
            $ul.append($li_1).append($li_2).append($li_3);

as a result, it is found that the empty li tag is repeated many times

Aug.09,2021

unclosed tags


after $li_2 and $li_3 are not closed
insert can be written together $ul.append ($li_1,$li_2,$li_3)


//li
var $li_2 = $("<li><li>"); //<li></li>

double tag elements with a slash at the end, such as

< / div >
unclosed tags will be recognized as two elements in high-version browsers, such as
  • banana
  • will be recognized as
  • banana
  • after actual compilation.

  • Banana
  • should be
  • Banana
  • . Notice the closing tag. The
  • should be followed by
  • .
    Menu