Home > Web Front-end > JS Tutorial > body text

jQuery action list soldiers dynamically add new elements to it

php中世界最好的语言
Release: 2018-04-19 14:00:02
Original
1440 people have browsed it

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>
Copy after login

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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!