jQuery中replaceAll()方法用法实例
2015-01-16 14:42
537 查看
本文实例讲述了jQuery中replaceAll()方法用法。分享给大家供大家参考。具体分析如下:
此方法用匹配元素去替换指定的内容。
replaceAll()方法的作用和replaceWith()方法是完全一样的。
语法结构:
参数列表:
参数 | 描述 |
content | 用于替换的内容。 |
selector | 用于查找所要被替换的元素 |
实例实例:
复制代码 代码如下:<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="//www.jb51.net/" />
<title>脚本之家</title>
<style type="text/css">
div{
width:100px;
height:100px;
border:1px solid blue;
}
p{
width:150px;
height:150px;
border:1px solid red;
}
</style>
<script src="jquery/1.9.0/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$("<div>这是div元素</div>").replaceAll("p");
});
});
</script>
</head>
<body>
<p>这是p元素</p>
<p>这是p元素</p>
<p>这是p元素</p>
<button>用div包裹每个段落</button>
</body>
</html>
希望本文所述对大家的jQuery程序设计有所帮助。
您可能感兴趣的文章:
相关文章推荐
- ruby中类的写法以及属性,实例变量,类方法的用法 .
- jquery中post方法用法实例
- jQuery中before()方法用法实例
- jQuery中val()方法用法实例
- jQuery中html()方法用法实例
- ruby中类的写法以及属性,实例变量,类方法的用法
- jQuery中ajax的get()方法用法实例
- jQuery中remove()方法用法实例
- jQuery中detach()方法用法实例
- jQuery中remove()方法用法实例
- Java Math.log10()方法用法实例教程 - 返回以10为底的double的值
- jQuery中fadeOut()方法用法实例
- jQuery中animate()方法用法实例
- jQuery中replaceWith()方法用法实例
- jQuery中fadeOut()方法用法实例
- jquery必须知道的一些常用特效方法。加用法实例
- jQuery中width()方法用法实例
- jQuery的css()方法用法实例
- jQuery中prepend()方法用法实例
- jQuery中ajax的post()方法用法实例