轻源码

  • QingYuanMa.com
  • 全球最大的互联网技术和资源下载平台
搜索
一起源码网 门户 前端设计 查看主题

jquery before()和after()在元素前后插入内容

发布者: miraclehk | 发布时间: 2018-1-11 12:00| 查看数: 5502| 评论数: 1|帖子模式

使用before()和after()在元素前后插入内容

使用before()after()方法可以在元素的前后插入内容,它们分别表示在整个元素的前面和后面插入指定的元素或内容,调用格式分别为:

$(selector).before(content)和$(selector).after(content)

其中参数content表示插入的内容,该内容可以是元素或HTML字符串。

 

  1. <body> 
  2.         <h3>before() after()方法在元素前后插入内容</h3> 
  3.         <span class="green">爱思资源网</span> 
  4.          
  5.         <script type="text/javascript"> 
  6.             var $htmla = "<span class='red'>Www.aseoe.Com</span>" 
  7.            var $htmlb = "<span class='red'>web前端开发</span>" 
  8.             $(".green").after($htmla); 
  9.              $(".green").before($htmlb); 
  10.         </script> 
  11.     </body> 
  12. </html> 




 

true jquery before()和after()在元素前后插入内容 show-13-472-1.html report 1748.5 使用before()和after()在元素前后插入内容使用before()和after()方法可以在元素的前后插入内容,它们分别表示在整个元素的前面和后面插入指定的元素或内容,调用格式分别为:$(selector) before(content)和$(sel

最新评论

沂蒙超超 发表于 2022-5-9 12:35
代码是怎么写出来的

浏览过的版块

轻源码让程序更轻更快

QingYuanMa.com

工作时间 周一至周六 8:00-17:30

侵权处理

客服QQ点击咨询

关注抖音号

定期抽VIP

Copyright © 2016-2021 https://www.171739.xyz/ 滇ICP备13200218号

快速回复 返回顶部 返回列表