jQuery append() 方法

jQuery 教程 · 2019-03-27 11:27:52

实例

在所有 <p> 元素结尾插入内容:

$(document).ready(function(){ $("#btn1").click(function(){ $("p").append(" <b>插入文本</b>."); }); $("#btn2").click(function(){ $("ol").append("<li>插入项</li>"); }); });

定义和用法

append() 方法在被选元素的结尾插入指定内容。

提示:如需在被选元素的开头插入内容,请使用 prepend() 方法。

语法

$(selector).append(content,function(index,html))

参数 描述
content 必需。规定要插入的内容(可包含 HTML 标签)。

可能的值:

  • HTML 元素
  • jQuery 对象
  • DOM 元素
function(index,html) 可选。规定返回待插入内容的函数。
  • index - 返回集合中元素的 index 位置。
  • html - 返回被选元素的当前 HTML。

点击查看所有 jQuery 教程 文章: https://www.codercto.com/courses/l/35.html

查看所有标签

C++ How to Program (5th Edition) (How to Program)

C++ How to Program (5th Edition) (How to Program)

Harvey & Paul) Deitel & Associates / Prentice Hall / 2005-01-05 / USD 98.00

With over 250,000 sold, Harvey and Paul Deitel's C++ How to Program is the world's best-selling introduction to C++ programming. Now, this classic has been thoroughly updated! The Deitels' groundbreak......一起来看看 《C++ How to Program (5th Edition) (How to Program)》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具