输入banner图图片脚本导航/分类

锋利的jQueryjQuery中的DOM操作_jquery

1 查找元素节点

var $x = $("selector").text()

2 查找属性节点

var $x = $("selector").attr("property")

3 创建节点

var $x = $("html")

4 插入节点

$("selector").append()
向每个匹配的元素内部追加内容
$("selector").appendTo()
等价于.append()操作符左右互换

$("selector").prepend()
向每个匹配的元素内部前置内容
$("selector").prependTo()
等价于.prepend()操作符左右互换

$("selector").after()
在每个匹配的元素之后插入内容
$("selector").insertAfter
等价于.after()操作符左右互换

$("selector").before()
在每个匹配的元素之前插入内容
$("selector").insertBefore()
等价于.before()操作符左右互换

5 移动节点

本书P70例:

代码如下: