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

查看所有标签

A Byte of Python

A Byte of Python

Swaroop C H / Lulu Marketplace / 2008-10-1 / USD 27.98

'A Byte of Python' is a book on programming using the Python language. It serves as a tutorial or guide to the Python language for a beginner audience. If all you know about computers is how to save t......一起来看看 《A Byte of Python》 这本书的介绍吧!

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

各进制数互转换器

MD5 加密
MD5 加密

MD5 加密工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试