zl程序教程

您现在的位置是:首页 >  前端

当前栏目

jquery文档操作wrap()方法实例简述

jQuery实例文档方法 操作 简述 wrap
2023-06-13 09:15:39 时间

本文实例讲述了jquery文档操作wrap()方法。分享给大家供大家参考。具体实现方法如下:

wrap()方法:是指用某个标签将某个元素包起来,即在外面多加一层标签。

复制代码代码如下:
<html>
<head>
<title>jquery文档操作:wrap()方法</title>
<scripttype="text/javascript"src="jquery-1.8.2.min.js"></script>
<scripttype="text/javascript">
 $(function(){
 $("button").click(function(){
  $("p").wrap("<div></div>");//在p标签外,多加一个div层
  $("div").css("color","blue");
 });
 });
</script>
</head>
<body>
<p>helloworld<br/>iloveyou!<br/>hhaha,goodmorning</p>
<button>wrap()方法</button>
</body>
</html>

希望本文所述对大家的jQuery程序设计有所帮助。