语法总结
li=document.createElement('li')
li.innerText = tag
$('#i1').append(li)
$(..).clone() 复制整个文本和Html格式
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <div> <input type="text"> <input type="button" value="添加" onclick="addElementr()"> <input type="button" value="删除" onclick="deleteElementr()"> <input type="button" value="复制" onclick="cloneElementr()"> <ul id="i1"> <li>1</li> <li>2</li> </ul> </div> <script src="../jquery-2.12.4.js"></script> <script> function addElementr() { tag = $(':text').val(); li = document.createElement('li'); li.innerHTML = tag; $('#i1').append(li) } function deleteElementr(){ index= $(':text').val(); $('#i1').children().eq(index).remove() } function cloneElementr() { index = $(':text').val(); tag = $('#i1').children().eq(index).clone(); $('#i1').append(tag); } </script> </body> </html>