Home >Web Front-end >JS Tutorial >jQuery add new element to dynamic list
This time I will bring you jQueryAdd new elements to the dynamic list, what are the precautions for jQuery to add new elements to the dynamic list, the following is a practical case, let's take a look one time.
Let’s take a look at the renderings first:
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 content, please pay attention to other related articles on the php Chinese website!
Recommended reading:
Practical jQuery drawer-style online customer service
Detailed instructions for using the image viewing plug-in Magnify
JS to merge the same cells in the table
##How to implement dynamic data paging with jQuery+ajax
The above is the detailed content of jQuery add new element to dynamic list. For more information, please follow other related articles on the PHP Chinese website!