Home > Backend Development > Python Tutorial > Detailed example of jQuery simple implementation of dynamically adding new elements to the list

Detailed example of jQuery simple implementation of dynamically adding new elements to the list

小云云
Release: 2017-12-26 09:13:06
Original
1671 people have browsed it

This article mainly introduces jQuery's simple method of dynamically adding new elements to a list, involving implementation techniques related to jQuery event response and dynamic operation of page elements. Friends who need it can refer to it. I hope it can help everyone.

Let’s take a look at the renderings first:

##The complete implementation code is as follows:

<!DOCTYPE html> 
<html> 
<head> 
<meta charset="UTF-8"> 
<title>www.jb51.net 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 () { 
    $(&#39;#btn&#39;).click(function () { 
      $(&#39;ol&#39;).append(&#39;<li>&#39;+$(&#39;#text&#39;).val()+&#39;</li>&#39;); 
    }); 
}); 
</script> 
</body> 
</html>
Copy after login

Related recommendations:


JavaScript method to delete elements and add new elements to the array splice()

C# Method to dynamically add new elements to the array

Share three methods of creating new elements

The above is the detailed content of Detailed example of jQuery simple implementation of dynamically adding new elements to the list. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template