jQuery prepend() 方法

jQuery 教程 · 2019-03-27 16:28:13

实例

在所有 <p> 元素开头插入内容:

$("button").click(function(){ $("p").prepend("<b>Prepended text</b>"); });

定义和用法

prepend() 方法在被选元素的开头插入指定内容。

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

语法

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

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

可能的值:

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

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

查看所有标签

Algorithms + Data Structures = Programs

Algorithms + Data Structures = Programs

Niklaus Wirth / Prentice Hall / 1975-11-11 / GBP 84.95

It might seem completely dated with all its examples written in the now outmoded Pascal programming language (well, unless you are one of those Delphi zealot trying to resist to the Java/.NET dominanc......一起来看看 《Algorithms + Data Structures = Programs》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

html转js在线工具
html转js在线工具

html转js在线工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换