wrap(html)
将‘html’的内容封装在匹配元素集合的每一个元素上。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("p").wrap("<div></div>");
});
</script>
<style>
div { border: 2px solid blue; }
p { background:yellow; margin:4px; }
</style>
</head>
<body>
<p>Hello</p>
<p>cruel</p>
<p>World</p>
</body>
</html>
$("p").wrap("<div></div>");
将‘<div></div>’封装在匹配p元素集合的每一个p元素上。使匹配p元素外都有一个‘div’元素。
分享到:
相关推荐
2.4 队列控制 30 2.4.1 queue(name) 30 2.4.2 queue(name, callback) 31 2.4.3 queue(name, queue) 32 2.4.4 dequeue(name) 33 2.4.5 clearQueue([queueName]) 34 2.5 插件机制 34 2.5.1 jQuery.fn.extend(object) ...
wrap(html|ele|fn) unwrap() wrapall(html|ele) wrapInner(html|ele|fn) 替换 replaceWith(content|fn) replaceAll(selector) 删除 empty() remove([expr]) detach([expr]) 复制 clone([Even[,deepEven]...
演示 jQuery hide() 函数,隐藏当前的 HTML 元素。 $("#test").hide() 演示 jQuery hide() 函数,隐藏 id="test" 的元素。 $("p").hide() 演示 jQuery hide() 函数,隐藏所有 <p> 元素。 $(".test").hide() ...
wrap(html|ele|fn) unwrap() wrapAll(html|ele) wrapInner(html|ele|fn) 替换 replaceWith(content|fn) replaceAll(selector) 删除 empty() remove([expr]) detach([expr]) 复制 clone([Even[,deepEven...
Wrap jQuery functionality around a single or multiple DOM Element(s). This function also accepts XML Documents and Window objects as valid arguments (even though they are not DOM Elements). 返回值 ...
get(index) index(subject) 数据缓存 data([name] , [value]) data(obj) removeData(name) $.data([el], [key], [val]) 队列控制 queue(name ,[cb|queue]) dequeue(name) clearQueue([queueName]) 插件机制 jQuery....