This time I will bring you jQueryOperation list soldiers to dynamically add new elements to it, jQuery operation list soldiers to dynamically add new elements to itWhat are the precautions, the following are Let’s take a look at practical cases.
The complete implementation code is as follows:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>jQuery列表添加新元素</title> <script src="jquery-1.7.2.min.js"></script> </head> <body> <h3>li列表:</h3> <ol> <li>jb51</li> <li>php</li> <li>javascript</li> <li>HTML5</li> </ol> <input type="text" id="text"> <input type="button" id="btn" value="添加"> <script type="text/javascript"> $(function () { $('#btn').click(function () { $('ol').append('<li>'+$('#text').val()+'</li>'); }); }); </script> </body> </html>
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the PHP Chinese website!
Recommended reading:
Use JS to make the function of resending the verification code after 60 seconds
JS string traversal and interception, Output and calculation operations
JS implements unlimited loading and paging function on the mobile terminal
The above is the detailed content of jQuery action list soldiers dynamically add new elements to it. For more information, please follow other related articles on the PHP Chinese website!