PRependTo()方法的定义和用法:
此方法把匹配的元素插入指定元素之前。
prependTo()方法的作用和prepend()方法是相同的,但是在语法上是有差别的,虽然在形式上看起来是一样的。
语法结构:
$(selector).prependTo(content)
实例列表:
参数
描述
selector
要被插入的匹配元素。
content
要被插入匹配元素的元素。
实例代码:
<!DOCTYPE html><html><head><metacharset="utf-8"><metaname="author"content="http://www.51texiao.cn/"/><title>蚂蚁部落</title><styletype="text/CSS">p{height:100px;width:100px;border:1px solid blue;}div{height:200px;width:200px;border:1px solid green;}</style><scriptsrc="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script><scripttype="text/javascript">$(document).ready(function(){
$("button").click(function(){
$("p").prependTo("div");
})
})</script></head><body><p>我是p的内容</p><div>我是div</div><button>点击查看效果</button></body></html>
原文地址是:http://www.51texiao.cn/jqueryjiaocheng/2015/0613/4049.html
最为原始地址是:http://www.softwhy.com/forum.php?mod=viewthread&tid=5283